From 8bf426b6b9449fb117fe3216eb4fa60db678ab90 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Tue, 15 Dec 2020 15:00:24 +0100 Subject: [PATCH 1/3] don't recompile shaders unnecessarily --- .github/workflows/ci.yml | 2 +- .github/workflows/nightly.yml | 2 +- .gitignore | 1 + Cargo.lock | 45 --------------------------- editor/Cargo.toml | 13 +++++--- editor/{build.rs => build_shaders.rs} | 28 ++++++++++------- editor/src/shaders/rect.frag | 2 ++ editor/src/shaders/rect.vert | 2 ++ 8 files changed, 31 insertions(+), 64 deletions(-) rename editor/{build.rs => build_shaders.rs} (76%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82ab08363c..f386154fa8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Install CI Libraries run: sudo ./ci/install-ci-libraries.sh 10 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 37f809efb5..934baf2e8f 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -9,7 +9,7 @@ jobs: name: Test and Build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: profile: minimal diff --git a/.gitignore b/.gitignore index 42a856f29f..5741484e8e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ vgcore.* #editors .idea/ +.vscode/ diff --git a/Cargo.lock b/Cargo.lock index 0a211dcfda..aabd2bbf8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,12 +69,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "anyhow" -version = "1.0.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7" - [[package]] name = "approx" version = "0.3.2" @@ -407,15 +401,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "cmake" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855" -dependencies = [ - "cc", -] - [[package]] name = "cocoa" version = "0.20.2" @@ -1234,12 +1219,6 @@ version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" -[[package]] -name = "glob" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" - [[package]] name = "glyph_brush" version = "0.7.0" @@ -2658,15 +2637,12 @@ dependencies = [ name = "roc_editor" version = "0.1.0" dependencies = [ - "anyhow", "arraystring", "bumpalo", "bytemuck", "cgmath", "env_logger 0.7.1", - "fs_extra", "futures", - "glob", "glyph_brush", "im", "im-rc", @@ -2697,7 +2673,6 @@ dependencies = [ "roc_types", "roc_unify", "roc_uniq", - "shaderc", "target-lexicon", "wgpu", "wgpu_glyph", @@ -3232,26 +3207,6 @@ dependencies = [ "opaque-debug", ] -[[package]] -name = "shaderc" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50b8aeaae10b9bda5cba66736a7e265f67698e912e1cc6a4678acba286e22be9" -dependencies = [ - "libc", - "shaderc-sys", -] - -[[package]] -name = "shaderc-sys" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b12d7c62d6732884c9dfab587503fa3a795b108df152415a89da23812d4737e" -dependencies = [ - "cmake", - "libc", -] - [[package]] name = "signal-hook-registry" version = "1.2.2" diff --git a/editor/Cargo.toml b/editor/Cargo.toml index 43d2ff5c29..4e1e639c8f 100644 --- a/editor/Cargo.toml +++ b/editor/Cargo.toml @@ -74,8 +74,11 @@ indoc = "0.3.3" quickcheck = "0.8" quickcheck_macros = "0.8" -[build-dependencies] -anyhow = "1.0" -fs_extra = "1.1" -glob = "0.3" -shaderc = "0.6" +# uncomment everything below if you have made changes to any shaders and +# want to compile them to .spv +#[build-dependencies] +#rayon = "1.5.0" +#anyhow = "1.0" +#fs_extra = "1.1" +#glob = "0.3" +#shaderc = "0.6" diff --git a/editor/build.rs b/editor/build_shaders.rs similarity index 76% rename from editor/build.rs rename to editor/build_shaders.rs index 7c80d06d23..52990c1c4c 100644 --- a/editor/build.rs +++ b/editor/build_shaders.rs @@ -2,9 +2,14 @@ use anyhow::*; use glob::glob; use std::fs::{read_to_string, write}; use std::path::PathBuf; +use rayon::prelude::*; -// Build script for shaders used from: -// https://sotrh.github.io/learn-wgpu/beginner/tutorial3-pipeline/#compiling-shaders-and-include-spirv +// Adapted from https://github.com/sotrh/learn-wgpu +// by Benjamin Hansen, licensed under the MIT license + + +// Rename this file to build.rs and uncomment the build-dependencies in Cargo.toml to compile +// the shaders into .spv files struct ShaderData { src: String, @@ -41,17 +46,16 @@ impl ShaderData { fn main() -> Result<()> { // Collect all shaders recursively within /src/ - let mut shader_paths = [ - glob("./src/**/*.vert")?, - glob("./src/**/*.frag")?, - glob("./src/**/*.comp")?, - ]; + let mut shader_paths = Vec::new(); + shader_paths.extend(glob("./src/**/*.vert")?); + shader_paths.extend(glob("./src/**/*.frag")?); + shader_paths.extend(glob("./src/**/*.comp")?); - // This could be parallelized - let shaders = shader_paths - .iter_mut() - .flatten() - .map(|glob_result| ShaderData::load(glob_result?)) + + let shaders = shader_paths.into_par_iter() + .map(|glob_result| { + ShaderData::load(glob_result?) + }) .collect::>>() .into_iter() .collect::>>()?; diff --git a/editor/src/shaders/rect.frag b/editor/src/shaders/rect.frag index dbd8c522f7..2246d723b6 100644 --- a/editor/src/shaders/rect.frag +++ b/editor/src/shaders/rect.frag @@ -2,6 +2,8 @@ // Taken from https://github.com/sotrh/learn-wgpu // by Benjamin Hansen, licensed under the MIT license +// Check build_shaders.rs on how to recompile shaders if you have made changes to this file + layout(location=0) in vec3 color; layout(location=0) out vec4 fColor; diff --git a/editor/src/shaders/rect.vert b/editor/src/shaders/rect.vert index 4be9792857..3f885aa159 100644 --- a/editor/src/shaders/rect.vert +++ b/editor/src/shaders/rect.vert @@ -3,6 +3,8 @@ // https://github.com/sotrh/learn-wgpu by Benjamin Hansen, licensed under the MIT license // https://github.com/cloudhead/rgx by Alexis Sellier, licensed under the MIT license +// Check build_shaders.rs on how to recompile shaders if you have made changes to this file + layout(set = 0, binding = 0) uniform Globals { // orthographic projection is used to transform pixel coords to the coordinate system used by wgpu mat4 ortho; From 6e3bd69e7c61f2bf2f53542158d0ef449d99bfcf Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Tue, 15 Dec 2020 15:21:20 +0100 Subject: [PATCH 2/3] rust fmt --- compiler/unify/src/unify.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/unify/src/unify.rs b/compiler/unify/src/unify.rs index 89fe4b44e9..c3767540ad 100644 --- a/compiler/unify/src/unify.rs +++ b/compiler/unify/src/unify.rs @@ -1239,5 +1239,8 @@ fn gather_tags( } fn is_recursion_var(subs: &Subs, var: Variable) -> bool { - matches!(subs.get_without_compacting(var).content, Content::RecursionVar { .. }) + matches!( + subs.get_without_compacting(var).content, + Content::RecursionVar { .. } + ) } From 1f3850126e3c237745bd57828cc5eca42f2c859e Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Tue, 15 Dec 2020 15:34:39 +0100 Subject: [PATCH 3/3] include shaders in repo --- editor/.gitignore | 2 +- editor/src/shaders/rect.frag.spv | Bin 0 -> 564 bytes editor/src/shaders/rect.vert.spv | Bin 0 -> 1360 bytes 3 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 editor/src/shaders/rect.frag.spv create mode 100644 editor/src/shaders/rect.vert.spv diff --git a/editor/.gitignore b/editor/.gitignore index 27ca244cf3..8b13789179 100644 --- a/editor/.gitignore +++ b/editor/.gitignore @@ -1 +1 @@ -*.spv + diff --git a/editor/src/shaders/rect.frag.spv b/editor/src/shaders/rect.frag.spv new file mode 100644 index 0000000000000000000000000000000000000000..ae9c49a4adb606ffe3801f3f3b56dec91d21682a GIT binary patch literal 564 zcmYk2%}T>i5QWF4Ke4rc7IY^SmqKx&B8a*W$tF<62MCfx2*k9sQE=z8`BZKM&v%YPgYY?=t;=L~esP9kV4f4A8Cu7h%Ea4C zR#4bg>?ual!E1qTo~D|8tEp*S3&JRv&x7zGikHi1U4G_ilxIa6CD|&C%j_dX=ht*u z5$EqoUC@%Ez8B2y*ZW1jSeb$G5pSRcRsBdD2TXm7Cvu3#W9Qb~{XqA&xT)e$dfozN z?^Iu3nZE&lU12=Hq3lZj4Js1ygr^09l3bU`fOT7R;?BX!vM@&okMl7@Y t3i_YK(mSj;rGIWzaqQUY#udl>N4dxUzJh-A)bVkvt-OcYuUuX!{s2T1ErS36 literal 0 HcmV?d00001 diff --git a/editor/src/shaders/rect.vert.spv b/editor/src/shaders/rect.vert.spv new file mode 100644 index 0000000000000000000000000000000000000000..116f55904733006a3db5bcfd84699f424e687d5e GIT binary patch literal 1360 zcmYk4-EPxB5QUedX+uj}O6dZI`V&XV8JY#a2$mvC*k;0G?~q!vigxG zQEIa!n%W|nRQ4(%uiwhE*(AN3wi9~FXy4gWuPeIaB8^Uy;yfv; zOze`&M}y;SR-M_Ox|uU|jGh%cO6}~UEvq=2B=Z;(AaWNyl+0Y{BcHPE;(V|hHRp~JkDK?|d| zjnNB6$EK=Mcc?q)oBg(Si}HbNNB7YO7(HA1@5=`=*0TolYN@v;yev;X+(0|@`x?Zs zKzTRh{jAwnuFE~(bs1|{nAuR5z6LtQjNqt!OCBw7)CMy*IO4aPJ^5(d zk*8-L-_;&H@SF!TS2%hh_nwU9@t#A!-cx_5Jv!)*`XhPHz!87g?BS^o<~#ZLW9_-i z$H4~;_e!saKGDtM%wI9QsSo-`+m;Ny%@6;_gkkJSFp2*Nfj2VFc>BiTx|J)K} AR{#J2 literal 0 HcmV?d00001