Skip to content

Commit 5aa7453

Browse files
committed
Revert "Replace usage of spirv-* binaries with spirv-tools rust crate (#117)"
This reverts commit 0bfe303.
1 parent 0bfe303 commit 5aa7453

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+176
-6490
lines changed

.github/workflows/ci.yaml

+12-44
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,25 @@ jobs:
1111
name: Test
1212
strategy:
1313
matrix:
14-
os: [macOS-latest, ubuntu-latest, windows-latest]
15-
include:
16-
- os: ubuntu-latest
17-
target: x86_64-unknown-linux-gnu
18-
- os: windows-latest
19-
target: x86_64-pc-windows-msvc
20-
- os: macOS-latest
21-
target: x86_64-apple-darwin
14+
os: [macos-latest, ubuntu-latest, windows-latest]
2215
runs-on: ${{ matrix.os }}
2316
env:
2417
spirv_tools_version: "20200928"
2518
steps:
26-
# Note that we are explicitly NOT checking out submodules, to validate
27-
# that we haven't accidentally enabled spirv-tools native compilation
28-
# and regressed CI times
2919
- uses: actions/checkout@v2
30-
with:
31-
submodules: "false"
3220
# Ubuntu does have `brew install spirv-tools`, but it installs from
3321
# source and so takes >8 minutes.
3422
- if: ${{ runner.os == 'Linux' }}
35-
name: Linux - Install native dependencies
3623
run: |
3724
sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
3825
mkdir "${HOME}/spirv-tools"
3926
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"
4027
echo "${HOME}/spirv-tools/install/bin" >> $GITHUB_PATH
4128
- if: ${{ runner.os == 'macOS' }}
42-
name: Mac - Install spirv-tools
4329
run: brew install spirv-tools
4430
# Currently SPIR-V tools aren't available in any package manager
4531
# on Windows that put the tools in the path.
4632
- if: ${{ runner.os == 'Windows' }}
47-
name: Windows - Install spirv-tools
4833
shell: bash
4934
run: |
5035
tmparch=$(mktemp)
@@ -54,42 +39,25 @@ jobs:
5439
- if: ${{ runner.os == 'Windows' }}
5540
# Runs separately to add spir-v tools to Powershell's Path.
5641
run: echo "$HOME/spirv-tools/install/bin" >> $env:GITHUB_PATH
57-
- name: Install rustup components
58-
run: rustup component add rust-src rustc-dev llvm-tools-preview
59-
# Fetch dependencies in a separate step to clearly show how long each part
60-
# of the testing takes
61-
- name: cargo fetch
62-
run: cargo fetch --target ${{ matrix.target }}
63-
- name: Run tests
64-
shell: bash
65-
run: .github/workflows/test.sh
66-
42+
- run: rustup component add rust-src rustc-dev llvm-tools-preview
43+
# See: https://github.com/EmbarkStudios/rust-gpu/issues/84
44+
- if: ${{ runner.os == 'macOS' }}
45+
run: cargo test --workspace --exclude example-runner
46+
- if: ${{ runner.os != 'macOS' }}
47+
run: cargo test --workspace
6748
lint:
6849
name: Lint
6950
runs-on: ubuntu-latest
7051
steps:
71-
# Note that we are explicitly NOT checking out submodules, to validate
72-
# that we haven't accidentally enabled spirv-tools native compilation
73-
# and regressed CI times
7452
- uses: actions/checkout@v2
75-
with:
76-
submodules: "false"
77-
- name: Install native dependencies
78-
run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
79-
- name: Install spirv-tools
80-
run: |
53+
- run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
54+
- run: |
8155
mkdir "${HOME}/spirv-tools"
8256
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"
8357
echo "${HOME}/spirv-tools/install/bin" >> $GITHUB_PATH
84-
- name: Install rustup components
85-
run: rustup component add rustfmt clippy rust-src rustc-dev llvm-tools-preview
86-
- name: Rustfmt
87-
run: cargo fmt --all -- --check
88-
- name: cargo fetch
89-
run: cargo fetch
90-
- name: Clippy
91-
run: .github/workflows/clippy.sh
92-
58+
- run: rustup component add rustfmt clippy rust-src rustc-dev llvm-tools-preview
59+
- run: cargo fmt --all -- --check
60+
- run: cargo clippy --workspace --all-targets -- -D warnings
9361
cargo-deny:
9462
runs-on: ubuntu-latest
9563
steps:

.github/workflows/clippy.sh

-42
This file was deleted.

.github/workflows/test.sh

-55
This file was deleted.

.gitmodules

-7
This file was deleted.

Cargo.lock

-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ members = [
55
"examples/wgpu-example-runner",
66
"examples/example-shader",
77
"examples/wgpu-example-shader",
8-
98
"rustc_codegen_spirv",
109
"spirv-builder",
1110
"spirv-std",
12-
"spirv-tools",
13-
"spirv-tools-sys",
1411
]

docs/src/introduction.md

+6-23
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
11
# Introduction
2-
32
Welcome to the Rust-GPU dev guide! This documentation is meant for documenting
43
how to use and develop on Rust-GPU.
54

65
## Getting started
76

87
1. Clone the repository.
98

10-
```shell
11-
git clone --recurse-submodules https://github.com/EmbarkStudios.com/rust-gpu
12-
```
13-
149
1. Install the prerequisites using the provided setup script. From the root of the project, run:
1510

1611
MacOS, Linux:
17-
1812
```shell
1913
sh setup.sh
2014
```
2115

2216
Windows:
23-
24-
```shell
17+
```
2518
setup.bat
2619
```
2720

2821
The setup script installs nightly Rust (required for now, see [#78](https://github.com/EmbarkStudios/rust-gpu/issues/78) for tracking issue).
2922

30-
1. **optional** Install [SPIRV-Tools](https://github.com/KhronosGroup/SPIRV-Tools#downloads) and add it to your `PATH`. You can skip this step if you just want to run examples with the defaults. See [Using installed SPIRV-Tools](#using-installed-spirv-tools) if you decide to go with this option.
23+
1. Install [SPIRV-Tools](https://github.com/KhronosGroup/SPIRV-Tools#downloads) and add it to your PATH (for now, eventually we will automatically build and link it instead of calling executables)
3124

3225
1. Next, look at the [examples](examples) folder. There are two projects here: [examples/example-shader](examples/example-shader) and [examples/example-runner](examples/example-runner). The example-shader project is a "GPU crate", one that will be compiled to a SPIR-V module. The example-runner project is a normal, CPU crate that uses vulkan to consume the example-shader SPIR-V module to display a shader.
3326

@@ -43,13 +36,15 @@ how to use and develop on Rust-GPU.
4336

4437
Be aware that this project is in a very early phase - if the above doesn't work, please [file an issue](https://github.com/EmbarkStudios/rust-gpu/issues)!
4538
46-
## Getting started, for power users who don't want to use spirv-builder
39+
## Getting started, for power users who don't want to use spirv-builder.
4740

4841
If you would like to build the compiler, `rustc_codegen_spirv` is the relevant folder. Install the prerequisites, as above, then, `cd rustc_codegen_spirv && cargo build`. This produces an .so file, located at `./target/debug/librustc_codegen_spirv.so` (or `.dll`/`.dylib` depending on your platform).
4942

5043
This file is a dynamically loaded backend for rustc - you may tell rustc to use it as a backend through the `-Z codegen-backend=...` flag. To pass this to rustc through cargo, set the environment variable `RUSTFLAGS="-Z codegen-backend=$PATH_TO_FILE"`.
5144

52-
Then, when building a GPU crate, we need to configure some flags when we call cargo. First, we need to build libcore ourselves - we obviously have no SPIR-V libcore installed on our system! Use the flag `-Z build-std=core`. Then, we need to tell rustc to generate SPIR-V instead of x86 code: `--target spirv-unknown-unknown`.
45+
Then, when building a GPU crate, we need to configure some flags when we call cargo. First, we need to build libcore
46+
ourselves - we obviously have no SPIR-V libcore installed on our system! Use the flag `-Z build-std=core`. Then, we need
47+
to tell rustc to generate SPIR-V instead of x86 code: `--target spirv-unknown-unknown`.
5348

5449
Overall, building your own SPIR-V crate looks like:
5550

@@ -66,15 +61,3 @@ To create a GPU crate, look at the [examples/example-shader](examples/example-sh
6661
6762
This is all a little convoluted, hence the [spirv-builder](spirv-builder) crate handles a lot of this.
6863
69-
## Using installed SPIRV-Tools
70-
71-
By default, all of the crates and examples in this repo will compile the `spirv-tools-sys` crate, including a lot of C++ code from [SPIRV-Tools](https://github.com/EmbarkStudios/SPIRV-Tools). If you don't want to build the C++ code because you already have [SPIRV-Tools](https://github.com/KhronosGroup/SPIRV-Tools#downloads) installed, or just don't want to spend more time compiling, you can build/run the crate with the `use-installed-tools` feature.
72-
73-
```shell
74-
cargo run \
75-
--manifest-path examples/example-runner/Cargo.toml \
76-
--features use-installed-tools \
77-
--no-default-features
78-
```
79-
80-
You should see `warning: use-installed-tools feature on, skipping compilation of C++ code` during the compilation, but otherwise the build will function just the same as if you compiled the C++ code, with the exception that it will fail if you don't have SPIRV-Tools installed correctly.

examples/example-runner-cpu/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ spirv-std = { path = "../../spirv-std" }
1414

1515
# for parallelism, not really needed though
1616
rayon = "1.5"
17+

examples/example-runner/Cargo.toml

+1-7
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ authors = ["Embark <[email protected]>"]
55
edition = "2018"
66
license = "MIT OR Apache-2.0"
77

8-
# See rustc_codegen_spirv/Cargo.toml for details on these features
9-
[features]
10-
default = ["use-compiled-tools"]
11-
use-installed-tools = ["spirv-builder/use-installed-tools"]
12-
use-compiled-tools = ["spirv-builder/use-compiled-tools"]
13-
148
[dependencies]
159
ash = "0.31"
1610
ash-window = "0.5"
@@ -22,4 +16,4 @@ winit = "0.23.0"
2216
ash-molten = { git = "https://github.com/EmbarkStudios/ash-molten", branch = "moltenvk-1.1.0" }
2317

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

examples/wgpu-example-runner/Cargo.toml

+1-7
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,13 @@ authors = ["Embark <[email protected]>"]
55
edition = "2018"
66
license = "MIT OR Apache-2.0"
77

8-
# See rustc_codegen_spirv/Cargo.toml for details on these features
9-
[features]
10-
default = ["use-compiled-tools"]
11-
use-installed-tools = ["spirv-builder/use-installed-tools"]
12-
use-compiled-tools = ["spirv-builder/use-compiled-tools"]
13-
148
[dependencies]
159
wgpu = "0.6.0"
1610
futures = { version = "0.3", default-features = false, features = ["std", "executor"] }
1711
winit = { version = "0.22.1", features = ["web-sys"] }
1812

1913
[build-dependencies]
20-
spirv-builder = { path = "../../spirv-builder", default-features = false }
14+
spirv-builder = { path = "../../spirv-builder" }
2115

2216
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
2317
wgpu-subscriber = "0.1.0"

rustc_codegen_spirv/Cargo.toml

-19
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,13 @@ repository = "https://github.com/EmbarkStudios/rust-gpu"
1212
[lib]
1313
crate-type = ["dylib"]
1414

15-
[features]
16-
# By default, the use-compiled-tools is enabled, as doesn't require additional
17-
# setup steps for the user. This does however mean that you will need to disable
18-
# default features and explicitly enable `use-installed-tools` if you are using
19-
# this in an environment with spirv-tools in PATH, and you don't want to take
20-
# the compile time cost
21-
default = ["use-compiled-tools"]
22-
# If enabled, uses spirv-tools binaries installed in PATH, instead of
23-
# compiling and linking the spirv-tools C++ code
24-
use-installed-tools = ["spirv-tools/use-installed-tools"]
25-
# If enabled will compile and link the C++ code for the spirv tools, the compiled
26-
# version is preferred if both this and `use-installed-tools` are enabled
27-
use-compiled-tools = ["spirv-tools/use-compiled-tools"]
28-
2915
[dependencies]
3016
bimap = "0.5"
3117
rspirv = { git = "https://github.com/gfx-rs/rspirv.git", rev = "f11f8797bd4df2d1d22cf10767b39a5119c57551" }
3218
tar = "0.4.30"
3319
thiserror = "1.0.20"
3420
topological-sort = "0.1"
3521

36-
[dependencies.spirv-tools]
37-
version = "0.1.0"
38-
path = "../spirv-tools"
39-
default-features = false
40-
4122
[dev-dependencies]
4223
pretty_assertions = "0.6"
4324
tempfile = "3.1"

0 commit comments

Comments
 (0)