Skip to content
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
78acbd5
Add spirv-headers and spirv-tools as submodules
Jake-Shadle Oct 23, 2020
ab53559
Add simple generator and the generated code needed for compilation
Jake-Shadle Oct 23, 2020
32fe2a1
Add first pass on spirv-tools-sys
Jake-Shadle Oct 23, 2020
095ec40
Add first pass on spirv-tools
Jake-Shadle Oct 23, 2020
cac9704
Replace invocation of spirv-opt with spirv-tools crate
Jake-Shadle Oct 23, 2020
6739ca9
Use C++11
Jake-Shadle Oct 23, 2020
95911d2
Placate clippy
Jake-Shadle Oct 23, 2020
2997eaa
Add validation, replacing spirv-val with the spirv-tools crate
Jake-Shadle Oct 23, 2020
f5cd86d
Fix MSVC warning
Jake-Shadle Oct 23, 2020
cbe33b7
Use patched spirv-tools
Jake-Shadle Oct 24, 2020
527388c
Fixup metadata
Jake-Shadle Oct 24, 2020
8635e68
Add same compiler flags as "official" build scripts
Jake-Shadle Oct 24, 2020
69a20e2
Update spirv-tools and generated files
Jake-Shadle Oct 25, 2020
77eb69e
Fixup
Jake-Shadle Oct 25, 2020
e499051
Add assembler and example
Jake-Shadle Oct 25, 2020
c951704
Use assembler in tests
Jake-Shadle Oct 25, 2020
26730ae
Oops, fix macos TARGET_OS
Jake-Shadle Oct 25, 2020
5040025
write -> write_all
Jake-Shadle Oct 25, 2020
67a526b
Start splitting spirv-tools into a compiled vs tool feature set
Jake-Shadle Oct 26, 2020
be90051
Checkpointing
Jake-Shadle Oct 26, 2020
e108852
Checkpoint
Jake-Shadle Oct 28, 2020
1ba0c89
Boop
Jake-Shadle Oct 28, 2020
91823a0
Get tests to work both with installed and compiled tools
Jake-Shadle Oct 28, 2020
66d4785
Cleanup CI config
Jake-Shadle Oct 29, 2020
f477b4c
Explicitly disable submodule checkout
Jake-Shadle Oct 29, 2020
b21e34f
Rustfmt
Jake-Shadle Oct 29, 2020
302f4c2
Rename features for consistency and fix clippy warnings
Jake-Shadle Oct 29, 2020
c8b3576
Split "core" crates from examples
Jake-Shadle Oct 29, 2020
d0715f5
Add run_clippy bash script
Jake-Shadle Oct 29, 2020
500b52a
Add test script
Jake-Shadle Oct 29, 2020
1a70688
Remove x flag
Jake-Shadle Oct 29, 2020
fcf5bd2
Newline
Jake-Shadle Oct 29, 2020
ca1ab0e
Actually print out errors from running val/opt
Jake-Shadle Oct 29, 2020
94ccf07
Revert drive-by import merging
Jake-Shadle Oct 29, 2020
938bb1d
Change intro to take the changes this PR has into account
Jake-Shadle Oct 29, 2020
b6eef4a
Actually run tests on Windows
Jake-Shadle Oct 29, 2020
be6c404
Fetch only the host target to reduce fetch times
Jake-Shadle Oct 29, 2020
0b0903a
Add more info when a spirv tool returns a non-zero exit code
Jake-Shadle Oct 29, 2020
68ae913
Rustfmt
Jake-Shadle Oct 29, 2020
034ddad
Switch tool assembler to use files to see if it fixes windows
Jake-Shadle Oct 29, 2020
52d1f7f
Use files for input and output for now until I can figure out Windows…
Jake-Shadle Oct 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 35 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,28 @@ jobs:
env:
spirv_tools_version: "20200928"
steps:
# Note that we are explicitly NOT checking out submodules, to validate
# that we haven't accidentally enabled spirv-tools native compilation
# and regressed CI times
- uses: actions/checkout@v2
with:
submodules: "false"
# Ubuntu does have `brew install spirv-tools`, but it installs from
# source and so takes >8 minutes.
- if: ${{ runner.os == 'Linux' }}
name: Linux - Install native dependencies
run: |
sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
mkdir "${HOME}/spirv-tools"
curl -fL https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/linux-clang-release/continuous/1305/20201026-063148/install.tgz | tar -xz -C "${HOME}/spirv-tools"
echo "${HOME}/spirv-tools/install/bin" >> $GITHUB_PATH
- if: ${{ runner.os == 'macOS' }}
name: Mac - Install spirv-tools
run: brew install spirv-tools
# Currently SPIR-V tools aren't available in any package manager
# on Windows that put the tools in the path.
- if: ${{ runner.os == 'Windows' }}
name: Windows - Install spirv-tools
shell: bash
run: |
tmparch=$(mktemp)
Expand All @@ -39,25 +47,41 @@ jobs:
- if: ${{ runner.os == 'Windows' }}
# Runs separately to add spir-v tools to Powershell's Path.
run: echo "$HOME/spirv-tools/install/bin" >> $env:GITHUB_PATH
- run: rustup component add rust-src rustc-dev llvm-tools-preview
# See: https://github.com/EmbarkStudios/rust-gpu/issues/84
- if: ${{ runner.os == 'macOS' }}
run: cargo test --workspace --exclude example-runner
- if: ${{ runner.os != 'macOS' }}
run: cargo test --workspace
- name: Install rustup components
run: rustup component add rust-src rustc-dev llvm-tools-preview
# Fetch dependencies in a separate step to clearly show how long each part
# of the testing takes
- name: cargo fetch
run: cargo fetch
- name: Run tests
run: .github/workflows/test.sh

lint:
name: Lint
runs-on: ubuntu-latest
steps:
# Note that we are explicitly NOT checking out submodules, to validate
# that we haven't accidentally enabled spirv-tools native compilation
# and regressed CI times
- uses: actions/checkout@v2
- run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
- run: |
with:
submodules: "false"
- name: Install native dependencies
run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
- name: Install spirv-tools
run: |
mkdir "${HOME}/spirv-tools"
curl -fL https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/linux-clang-release/continuous/1305/20201026-063148/install.tgz | tar -xz -C "${HOME}/spirv-tools"
echo "${HOME}/spirv-tools/install/bin" >> $GITHUB_PATH
- run: rustup component add rustfmt clippy rust-src rustc-dev llvm-tools-preview
- run: cargo fmt --all -- --check
- run: cargo clippy --workspace --all-targets -- -D warnings
- name: Install rustup components
run: rustup component add rustfmt clippy rust-src rustc-dev llvm-tools-preview
- name: Rustfmt
run: cargo fmt --all -- --check
- name: cargo fetch
run: cargo fetch
- name: Clippy
run: .github/workflows/clippy.sh

cargo-deny:
runs-on: ubuntu-latest
steps:
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/clippy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -e

if [[ -z "${CI}" ]]; then
FEAT="use-compiled-tools"
else
FEAT="use-installed-tools"
fi

function clippy() {
echo ::group::"$1"
cargo clippy \
--manifest-path "$1/Cargo.toml" \
--no-default-features \
--features "$FEAT" \
--all-targets \
-- -D warnings
echo ::endgroup::
}

function clippy_no_features() {
echo ::group::"$1"
cargo clippy \
--manifest-path "$1/Cargo.toml" \
--all-targets \
-- -D warnings
echo ::endgroup::
}

# Core crates
clippy spirv-tools-sys
clippy spirv-tools
clippy rustc_codegen_spirv
clippy spirv-builder

# Examples
clippy examples/example-runner
clippy examples/wgpu-example-runner

clippy_no_features examples/example-runner-cpu
clippy_no_features examples/example-shader
clippy_no_features examples/wgpu-example-shader
55 changes: 55 additions & 0 deletions .github/workflows/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
set -e

if [[ -z "${CI}" ]]; then
FEAT="use-compiled-tools"
else
FEAT="use-installed-tools"
fi

os=$1

function cargo_test() {
echo ::group::"$1 build"
cargo test \
--manifest-path "$1/Cargo.toml" \
--no-default-features \
--features "$FEAT" \
--no-run
echo ::endgroup::

echo ::group::"$1 test"
cargo test \
--manifest-path "$1/Cargo.toml" \
--no-default-features \
--features "$FEAT"
echo ::endgroup::
}

function cargo_test_no_features() {
echo ::group::"$1 build"
cargo test --manifest-path "$1/Cargo.toml" --no-run
echo ::endgroup::

echo ::group::"$1 test"
cargo test --manifest-path "$1/Cargo.toml"
echo ::endgroup::
}

# Core crates
cargo_test spirv-tools-sys
cargo_test spirv-tools
cargo_test rustc_codegen_spirv
cargo_test spirv-builder

# Examples
# See: https://github.com/EmbarkStudios/rust-gpu/issues/84
if [[ -z "${CI}" && "$os" != "macOS" ]]; then
cargo_test examples/example-runner
fi

cargo_test examples/wgpu-example-runner

cargo_test_no_features examples/example-runner-cpu
cargo_test_no_features examples/example-shader
cargo_test_no_features examples/wgpu-example-shader
7 changes: 7 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[submodule "spirv-tools-sys/spirv-headers"]
path = spirv-tools-sys/spirv-headers
url = https://github.com/KhronosGroup/SPIRV-Headers.git
[submodule "spirv-tools-sys/spirv-tools"]
path = spirv-tools-sys/spirv-tools
url = https://github.com/EmbarkStudios/SPIRV-Tools.git
branch = patch-to-string
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ members = [
"examples/wgpu-example-runner",
"examples/example-shader",
"examples/wgpu-example-shader",

"rustc_codegen_spirv",
"spirv-builder",
"spirv-std",
"spirv-tools",
"spirv-tools-sys",
]
1 change: 0 additions & 1 deletion examples/example-runner-cpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ spirv-std = { path = "../../spirv-std" }

# for parallelism, not really needed though
rayon = "1.5"

8 changes: 7 additions & 1 deletion examples/example-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ authors = ["Embark <[email protected]>"]
edition = "2018"
license = "MIT OR Apache-2.0"

# See rustc_codegen_spirv/Cargo.toml for details on these features
[features]
default = ["use-compiled-tools"]
use-installed-tools = ["spirv-builder/use-installed-tools"]
use-compiled-tools = ["spirv-builder/use-compiled-tools"]

[dependencies]
ash = "0.31"
ash-window = "0.5"
Expand All @@ -16,4 +22,4 @@ winit = "0.23.0"
ash-molten = { git = "https://github.com/EmbarkStudios/ash-molten", branch = "moltenvk-1.1.0" }

[build-dependencies]
spirv-builder = { path = "../../spirv-builder" }
spirv-builder = { path = "../../spirv-builder", default-features = false }
8 changes: 7 additions & 1 deletion examples/wgpu-example-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ authors = ["Embark <[email protected]>"]
edition = "2018"
license = "MIT OR Apache-2.0"

# See rustc_codegen_spirv/Cargo.toml for details on these features
[features]
default = ["use-compiled-tools"]
use-installed-tools = ["spirv-builder/use-installed-tools"]
use-compiled-tools = ["spirv-builder/use-compiled-tools"]

[dependencies]
wgpu = "0.6.0"
futures = { version = "0.3", default-features = false, features = ["std", "executor"] }
winit = { version = "0.22.1", features = ["web-sys"] }

[build-dependencies]
spirv-builder = { path = "../../spirv-builder" }
spirv-builder = { path = "../../spirv-builder", default-features = false }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
wgpu-subscriber = "0.1.0"
Expand Down
19 changes: 19 additions & 0 deletions rustc_codegen_spirv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,32 @@ repository = "https://github.com/EmbarkStudios/rust-gpu"
[lib]
crate-type = ["dylib"]

[features]
# By default, the use-compiled-tools is enabled, as doesn't require additional
# setup steps for the user. This does however mean that you will need to disable
# default features and explicitly enable `use-installed-tools` if you are using
# this in an environment with spirv-tools in PATH, and you don't want to take
# the compile time cost
default = ["use-compiled-tools"]
# If enabled, uses spirv-tools binaries installed in PATH, instead of
# compiling and linking the spirv-tools C++ code
use-installed-tools = ["spirv-tools/use-installed-tools"]
# If enabled will compile and link the C++ code for the spirv tools, the compiled
# version is preferred if both this and `use-installed-tools` are enabled
use-compiled-tools = ["spirv-tools/use-compiled-tools"]

[dependencies]
bimap = "0.5"
rspirv = { git = "https://github.com/gfx-rs/rspirv.git", rev = "f11f8797bd4df2d1d22cf10767b39a5119c57551" }
tar = "0.4.30"
thiserror = "1.0.20"
topological-sort = "0.1"

[dependencies.spirv-tools]
version = "0.1.0"
path = "../spirv-tools"
default-features = false

[dev-dependencies]
pretty_assertions = "0.6"
tempfile = "3.1"
Loading