Skip to content

Commit 9208b9e

Browse files
authored
fix: rebuilt shader linkage should only create a diff if Rust code has changed (#146)
* fix: rebuilt shader linkage should only create a diff if Rust code has changed * CI improvements
1 parent 092c64c commit 9208b9e

File tree

6 files changed

+189
-140
lines changed

6 files changed

+189
-140
lines changed

.cargo/config.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,3 @@ shaders = "gpu toml crates/renderling"
44
[build]
55
rustflags = ["--cfg=web_sys_unstable_apis"]
66
rustdocflags = ["--cfg=web_sys_unstable_apis"]
7-
8-
9-
[target.x86_64-pc-windows-msvc]
10-
rustflags = ["-Zshare-generics=off"]

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
* text=auto
12
*.spv binary
23
*.wgsl binary

.github/workflows/push.yaml

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Happens on push to main, and all PRs
12
name: push
23

34
on:
@@ -11,35 +12,86 @@ env:
1112
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1213

1314
jobs:
15+
# Installs `cargo-gpu` and sets the cache directory for subsequent jobs
16+
install-cargo-gpu:
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest, macos-latest, windows-latest]
20+
runs-on: ${{ matrix.os }}
21+
defaults:
22+
run:
23+
shell: bash
24+
env:
25+
RUST_LOG: debug
26+
RUNNER_OS: ${{ matrix.os }}
27+
outputs:
28+
cachepath-macOS: ${{ steps.cachepathstep.outputs.cachepath-macOS }}
29+
cachepath-Linux: ${{ steps.cachepathstep.outputs.cachepath-Linux }}
30+
cachepath-Windows: ${{ steps.cachepathstep.outputs.cachepath-Windows }}
31+
steps:
32+
- uses: actions/checkout@v2
33+
- uses: actions/cache@v4
34+
with:
35+
path: ~/.cargo
36+
key: cargo-cache-${{ runner.os }}
37+
- uses: moonrepo/setup-rust@v1
38+
- run: rustup default stable
39+
- run: rustup update
40+
- run: cargo install --git https://github.com/rust-gpu/cargo-gpu cargo-gpu
41+
- id: cachepathstep
42+
run: |
43+
CACHE_PATH=`cargo gpu show --cache-directory`
44+
echo $CACHE_PATH
45+
echo "cachepath-$RUNNER_OS=$CACHE_PATH" >> "$GITHUB_OUTPUT"
46+
47+
# Builds the shaders and ensures there is no git diff
1448
renderling-build-shaders:
15-
runs-on: ubuntu-latest
49+
needs: install-cargo-gpu
50+
strategy:
51+
matrix:
52+
os: [ubuntu-latest, macos-latest, windows-latest]
53+
runs-on: ${{ matrix.os }}
54+
defaults:
55+
run:
56+
shell: bash
57+
env:
58+
RUST_LOG: debug
1659
steps:
1760
- uses: actions/checkout@v2
1861
- uses: actions/cache@v4
1962
with:
20-
path: ~/.cache/rust-gpu
21-
key: 0-${{ runner.os }}
63+
path: ~/.cargo
64+
key: cargo-cache-${{ runner.os }}
65+
- uses: actions/cache@v4
66+
with:
67+
path: |
68+
${{ needs.install-cargo-gpu.outputs.cachepath-macOS }}
69+
${{ needs.install-cargo-gpu.outputs.cachepath-Linux }}
70+
${{ needs.install-cargo-gpu.outputs.cachepath-Windows }}
71+
key: rust-gpu-cache-0-${{ runner.os }}
2272
- uses: moonrepo/setup-rust@v1
23-
- run: RUST_LOG=trace cargo install --git https://github.com/rust-gpu/cargo-gpu
2473
- run: rm -rf crates/renderling/src/linkage/* crates/renderling/shaders
25-
- run: RUST_LOG=trace cargo shaders
74+
- run: cargo shaders
2675
- run: cargo build -p renderling
2776
- run: git diff --exit-code --no-ext-diff
2877

78+
# BAU clippy lints
2979
renderling-clippy:
3080
runs-on: ubuntu-latest
3181
steps:
3282
- uses: actions/checkout@v2
3383
- uses: moonrepo/setup-rust@v1
3484
- run: cargo clippy
3585

86+
# Ensures the example glTF viewer compiles
3687
renderling-build-example:
3788
runs-on: ubuntu-latest
3889
steps:
3990
- uses: actions/checkout@v2
4091
- uses: moonrepo/setup-rust@v1
4192
- run: cargo build -p example
4293

94+
# BAU tests
4395
renderling-test-linux:
4496
runs-on: ubuntu-latest
4597
steps:

crates/renderling/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ spirv-std = { version = "0.9" }
4747
# dependencies for GPU code
4848
[target.'cfg(target_arch = "spirv")'.dependencies]
4949
crabslab = { workspace = true, features = ["glam"] }
50-
half = { version = "2.3", default-features = false }
5150
glam = { workspace = true, default-features = false, features = ["libm"] }
5251

5352
# dependencies for CPU code

crates/renderling/src/color.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub fn linear_xfer_u16(c: &mut u16) {
1616
*c = ((*c as f32 / 65535.0).powf(2.2) * 65535.0) as u16;
1717
}
1818

19+
#[cfg(not(target_arch = "spirv"))]
1920
pub fn linear_xfer_f16(c: &mut u16) {
2021
let mut f = half::f16::from_bits(*c).to_f32();
2122
linear_xfer_f32(&mut f);

gltf/SimpleSkin.gltf

Lines changed: 130 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,131 @@
1-
{
2-
"scene" : 0,
3-
"scenes" : [ {
4-
"nodes" : [ 0, 1 ]
5-
} ],
6-
7-
"nodes" : [ {
8-
"skin" : 0,
9-
"mesh" : 0
10-
}, {
11-
"children" : [ 2 ]
12-
}, {
13-
"translation" : [ 0.0, 1.0, 0.0 ],
14-
"rotation" : [ 0.0, 0.0, 0.0, 1.0 ]
15-
} ],
16-
17-
"meshes" : [ {
18-
"primitives" : [ {
19-
"attributes" : {
20-
"POSITION" : 1,
21-
"JOINTS_0" : 2,
22-
"WEIGHTS_0" : 3
23-
},
24-
"indices" : 0
25-
} ]
26-
} ],
27-
28-
"skins" : [ {
29-
"inverseBindMatrices" : 4,
30-
"joints" : [ 1, 2 ]
31-
} ],
32-
33-
"animations" : [ {
34-
"channels" : [ {
35-
"sampler" : 0,
36-
"target" : {
37-
"node" : 2,
38-
"path" : "rotation"
39-
}
40-
} ],
41-
"samplers" : [ {
42-
"input" : 5,
43-
"interpolation" : "LINEAR",
44-
"output" : 6
45-
} ]
46-
} ],
47-
48-
"buffers" : [ {
49-
"uri" : "data:application/gltf-buffer;base64,AAABAAMAAAADAAIAAgADAAUAAgAFAAQABAAFAAcABAAHAAYABgAHAAkABgAJAAgAAAAAvwAAAAAAAAAAAAAAPwAAAAAAAAAAAAAAvwAAAD8AAAAAAAAAPwAAAD8AAAAAAAAAvwAAgD8AAAAAAAAAPwAAgD8AAAAAAAAAvwAAwD8AAAAAAAAAPwAAwD8AAAAAAAAAvwAAAEAAAAAAAAAAPwAAAEAAAAAA",
50-
"byteLength" : 168
51-
}, {
52-
"uri" : "data:application/gltf-buffer;base64,AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAABAPwAAgD4AAAAAAAAAAAAAQD8AAIA+AAAAAAAAAAAAAAA/AAAAPwAAAAAAAAAAAAAAPwAAAD8AAAAAAAAAAAAAgD4AAEA/AAAAAAAAAAAAAIA+AABAPwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAA=",
53-
"byteLength" : 320
54-
}, {
55-
"uri" : "data:application/gltf-buffer;base64,AACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIC/AAAAAAAAgD8=",
56-
"byteLength" : 128
57-
}, {
58-
"uri" : "data:application/gltf-buffer;base64,AAAAAAAAAD8AAIA/AADAPwAAAEAAACBAAABAQAAAYEAAAIBAAACQQAAAoEAAALBAAAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAkxjEPkSLbD8AAAAAAAAAAPT9ND/0/TQ/AAAAAAAAAAD0/TQ/9P00PwAAAAAAAAAAkxjEPkSLbD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAkxjEvkSLbD8AAAAAAAAAAPT9NL/0/TQ/AAAAAAAAAAD0/TS/9P00PwAAAAAAAAAAkxjEvkSLbD8AAAAAAAAAAAAAAAAAAIA/",
59-
"byteLength" : 240
60-
} ],
61-
62-
"bufferViews" : [ {
63-
"buffer" : 0,
64-
"byteLength" : 48,
65-
"target" : 34963
66-
}, {
67-
"buffer" : 0,
68-
"byteOffset" : 48,
69-
"byteLength" : 120,
70-
"target" : 34962
71-
}, {
72-
"buffer" : 1,
73-
"byteLength" : 320,
74-
"byteStride" : 16
75-
}, {
76-
"buffer" : 2,
77-
"byteLength" : 128
78-
}, {
79-
"buffer" : 3,
80-
"byteLength" : 240
81-
} ],
82-
83-
"accessors" : [ {
84-
"bufferView" : 0,
85-
"componentType" : 5123,
86-
"count" : 24,
87-
"type" : "SCALAR"
88-
}, {
89-
"bufferView" : 1,
90-
"componentType" : 5126,
91-
"count" : 10,
92-
"type" : "VEC3",
93-
"max" : [ 0.5, 2.0, 0.0 ],
94-
"min" : [ -0.5, 0.0, 0.0 ]
95-
}, {
96-
"bufferView" : 2,
97-
"componentType" : 5123,
98-
"count" : 10,
99-
"type" : "VEC4"
100-
}, {
101-
"bufferView" : 2,
102-
"byteOffset" : 160,
103-
"componentType" : 5126,
104-
"count" : 10,
105-
"type" : "VEC4"
106-
}, {
107-
"bufferView" : 3,
108-
"componentType" : 5126,
109-
"count" : 2,
110-
"type" : "MAT4"
111-
}, {
112-
"bufferView" : 4,
113-
"componentType" : 5126,
114-
"count" : 12,
115-
"type" : "SCALAR",
116-
"max" : [ 5.5 ],
117-
"min" : [ 0.0 ]
118-
}, {
119-
"bufferView" : 4,
120-
"byteOffset" : 48,
121-
"componentType" : 5126,
122-
"count" : 12,
123-
"type" : "VEC4",
124-
"max" : [ 0.0, 0.0, 0.707, 1.0 ],
125-
"min" : [ 0.0, 0.0, -0.707, 0.707 ]
126-
} ],
127-
128-
"asset" : {
129-
"version" : "2.0"
130-
}
1+
{
2+
"scene" : 0,
3+
"scenes" : [ {
4+
"nodes" : [ 0, 1 ]
5+
} ],
6+
7+
"nodes" : [ {
8+
"skin" : 0,
9+
"mesh" : 0
10+
}, {
11+
"children" : [ 2 ]
12+
}, {
13+
"translation" : [ 0.0, 1.0, 0.0 ],
14+
"rotation" : [ 0.0, 0.0, 0.0, 1.0 ]
15+
} ],
16+
17+
"meshes" : [ {
18+
"primitives" : [ {
19+
"attributes" : {
20+
"POSITION" : 1,
21+
"JOINTS_0" : 2,
22+
"WEIGHTS_0" : 3
23+
},
24+
"indices" : 0
25+
} ]
26+
} ],
27+
28+
"skins" : [ {
29+
"inverseBindMatrices" : 4,
30+
"joints" : [ 1, 2 ]
31+
} ],
32+
33+
"animations" : [ {
34+
"channels" : [ {
35+
"sampler" : 0,
36+
"target" : {
37+
"node" : 2,
38+
"path" : "rotation"
39+
}
40+
} ],
41+
"samplers" : [ {
42+
"input" : 5,
43+
"interpolation" : "LINEAR",
44+
"output" : 6
45+
} ]
46+
} ],
47+
48+
"buffers" : [ {
49+
"uri" : "data:application/gltf-buffer;base64,AAABAAMAAAADAAIAAgADAAUAAgAFAAQABAAFAAcABAAHAAYABgAHAAkABgAJAAgAAAAAvwAAAAAAAAAAAAAAPwAAAAAAAAAAAAAAvwAAAD8AAAAAAAAAPwAAAD8AAAAAAAAAvwAAgD8AAAAAAAAAPwAAgD8AAAAAAAAAvwAAwD8AAAAAAAAAPwAAwD8AAAAAAAAAvwAAAEAAAAAAAAAAPwAAAEAAAAAA",
50+
"byteLength" : 168
51+
}, {
52+
"uri" : "data:application/gltf-buffer;base64,AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAABAPwAAgD4AAAAAAAAAAAAAQD8AAIA+AAAAAAAAAAAAAAA/AAAAPwAAAAAAAAAAAAAAPwAAAD8AAAAAAAAAAAAAgD4AAEA/AAAAAAAAAAAAAIA+AABAPwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAA=",
53+
"byteLength" : 320
54+
}, {
55+
"uri" : "data:application/gltf-buffer;base64,AACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIC/AAAAAAAAgD8=",
56+
"byteLength" : 128
57+
}, {
58+
"uri" : "data:application/gltf-buffer;base64,AAAAAAAAAD8AAIA/AADAPwAAAEAAACBAAABAQAAAYEAAAIBAAACQQAAAoEAAALBAAAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAkxjEPkSLbD8AAAAAAAAAAPT9ND/0/TQ/AAAAAAAAAAD0/TQ/9P00PwAAAAAAAAAAkxjEPkSLbD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAkxjEvkSLbD8AAAAAAAAAAPT9NL/0/TQ/AAAAAAAAAAD0/TS/9P00PwAAAAAAAAAAkxjEvkSLbD8AAAAAAAAAAAAAAAAAAIA/",
59+
"byteLength" : 240
60+
} ],
61+
62+
"bufferViews" : [ {
63+
"buffer" : 0,
64+
"byteLength" : 48,
65+
"target" : 34963
66+
}, {
67+
"buffer" : 0,
68+
"byteOffset" : 48,
69+
"byteLength" : 120,
70+
"target" : 34962
71+
}, {
72+
"buffer" : 1,
73+
"byteLength" : 320,
74+
"byteStride" : 16
75+
}, {
76+
"buffer" : 2,
77+
"byteLength" : 128
78+
}, {
79+
"buffer" : 3,
80+
"byteLength" : 240
81+
} ],
82+
83+
"accessors" : [ {
84+
"bufferView" : 0,
85+
"componentType" : 5123,
86+
"count" : 24,
87+
"type" : "SCALAR"
88+
}, {
89+
"bufferView" : 1,
90+
"componentType" : 5126,
91+
"count" : 10,
92+
"type" : "VEC3",
93+
"max" : [ 0.5, 2.0, 0.0 ],
94+
"min" : [ -0.5, 0.0, 0.0 ]
95+
}, {
96+
"bufferView" : 2,
97+
"componentType" : 5123,
98+
"count" : 10,
99+
"type" : "VEC4"
100+
}, {
101+
"bufferView" : 2,
102+
"byteOffset" : 160,
103+
"componentType" : 5126,
104+
"count" : 10,
105+
"type" : "VEC4"
106+
}, {
107+
"bufferView" : 3,
108+
"componentType" : 5126,
109+
"count" : 2,
110+
"type" : "MAT4"
111+
}, {
112+
"bufferView" : 4,
113+
"componentType" : 5126,
114+
"count" : 12,
115+
"type" : "SCALAR",
116+
"max" : [ 5.5 ],
117+
"min" : [ 0.0 ]
118+
}, {
119+
"bufferView" : 4,
120+
"byteOffset" : 48,
121+
"componentType" : 5126,
122+
"count" : 12,
123+
"type" : "VEC4",
124+
"max" : [ 0.0, 0.0, 0.707, 1.0 ],
125+
"min" : [ 0.0, 0.0, -0.707, 0.707 ]
126+
} ],
127+
128+
"asset" : {
129+
"version" : "2.0"
130+
}
131131
}

0 commit comments

Comments
 (0)