Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
[build]
target-dir = "target"

[alias]
# We can't use `--package xtask` since we don't have a workspace at the root of this repo.
# Instead, we have one workspace per template expansion in `generated`, which wouldn't mix with an external xtask crate.
# So xtask is limited to the root of the repo, unfortunately.
xtask = "run --manifest-path=./xtask/Cargo.toml --"
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Firestar99
129 changes: 129 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
on:
push:
branches:
- main
pull_request:
merge_group:

name: CI

# Cancel PR actions on new commits
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
name: Test
strategy:
fail-fast: false
matrix:
os: [ ubuntu-24.04, windows-2022, macOS-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: install nextest
uses: taiki-e/install-action@v2
with:
tool: nextest
- name: Install Vulkan SDK
uses: jakoch/install-vulkan-sdk-action@v1
with:
vulkan_version: 1.4.321.0
install_runtime: true
cache: true
stripdown: true

# FIXME(eddyb) consider using lavapipe instead, or even trying both.
install_swiftshader: true
# install_lavapipe: true
- if: ${{ runner.os == 'Linux' }}
name: Linux - Install native dependencies
run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
# just need a random command that forces the installation of rust-toolchain
# figure out native target triple while we're at it
- name: install rust-toolchain
run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV"
- name: xtask cargo fetch --locked
run: cd xtask && cargo fetch --locked --target $TARGET
- name: xtask build
run: cd xtask && cargo build
- name: xtask generate
run: cargo xtask generate
- name: cargo fetch --locked
run: cargo xtask generate -x "cargo fetch --locked --target $TARGET"
- name: cargo build
run: cargo xtask generate -x "cargo build"
- name: cargo test
run: cargo xtask generate -x "cargo nextest run"

# This allows us to have a single job we can branch protect on, rather than needing
# to update the branch protection rules when the test matrix changes
test_success:
runs-on: ubuntu-24.04
needs: [test, lint]
# Hack for buggy GitHub Actions behavior with skipped checks: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
if: ${{ always() }}
steps:
# Another hack is to actually check the status of the dependencies or else it'll fall through
- run: |
echo "Checking statuses..."
[[ "${{ needs.test.result }}" == "success" ]] || exit 1
[[ "${{ needs.xtask-test.result }}" == "success" ]] || exit 1
[[ "${{ needs.lint.result }}" == "success" ]] || exit 1

xtask-test:
name: xtask test
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: install nextest
uses: taiki-e/install-action@v2
with:
tool: nextest
- if: ${{ runner.os == 'Linux' }}
name: Linux - Install native dependencies
run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
# just need a random command that forces the installation of rust-toolchain
# figure out native target triple while we're at it
- name: install rust-toolchain
run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV"
- name: xtask cargo fetch --locked
run: cd xtask && cargo fetch --locked --target $TARGET
- name: xtask build
run: cd xtask && cargo build
- name: xtask test
run: cd xtask && cargo nextest run
- name: xtask fmt
run: cd xtask && cargo fmt --all -- --check
- name: xtask clippy
run: cd xtask && cargo clippy --all-targets -- -D warnings

lint:
name: Lint
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- if: ${{ runner.os == 'Linux' }}
name: Linux - Install native dependencies
run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
# just need a random command that forces the installation of rust-toolchain
# figure out native target triple while we're at it
- name: install rust-toolchain
run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV"
- name: xtask cargo fetch --locked
run: cd xtask && cargo fetch --locked
- name: xtask build
run: cd xtask && cargo build
- name: xtask generate
run: cargo xtask generate
- name: cargo fetch --locked
run: cargo xtask generate -x "cargo fetch --locked"
- name: fmt
run: cargo xtask generate -x "cargo fmt --all -- --check"
- name: clippy
run: cargo xtask generate -x "cargo clippy --all-targets -- -D warnings"

defaults:
run:
shell: bash
6 changes: 6 additions & 0 deletions ash-graphics/Cargo.toml → ash-graphics/Cargo.toml.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ repository = ""
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }

[workspace.dependencies]
{% if integration_type == "spirv-builder" -%}
# The version of the dependencies `spirv-builder` and `spirv-std` must match exactly!
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "6fb875068d0d35b1a81ae89b73cf7a464f8c60f7" }
{% endif -%}
{% if integration_type == "cargo-gpu" -%}
cargo-gpu = { git = "https://github.com/Rust-GPU/cargo-gpu", rev = "bf24eb6060e0c7b0013eceddd23b5d7cee68f4cc" }
{% endif -%}
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "6fb875068d0d35b1a81ae89b73cf7a464f8c60f7" }

glam = { version = "0.30.9", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ repository.workspace = true
[lints]
workspace = true

{% if integration_type == "spirv-builder" -%}
[features]
default = ["use-compiled-tools"]
use-installed-tools = ["spirv-builder/use-installed-tools"]
use-compiled-tools = ["spirv-builder/use-compiled-tools"]
{% endif -%}

[dependencies]
ash-graphics-shaders = { path = "../ash-graphics-shaders" }
Expand All @@ -26,5 +28,10 @@ anyhow.workspace = true
bytemuck.workspace = true

[build-dependencies]
{% if integration_type == "spirv-builder" -%}
spirv-builder.workspace = true
{% endif -%}
{% if integration_type == "cargo-gpu" -%}
cargo-gpu.workspace = true
{% endif -%}
anyhow.workspace = true
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{% if integration_type == "spirv-builder" -%}
use spirv_builder::{MetadataPrintout, ShaderPanicStrategy, SpirvBuilder};
{% endif -%}
{% if integration_type == "cargo-gpu" -%}
use cargo_gpu::Install;
use cargo_gpu::spirv_builder::{MetadataPrintout, ShaderPanicStrategy};
{% endif -%}
use std::path::PathBuf;

pub fn main() -> anyhow::Result<()> {
Expand All @@ -8,9 +14,13 @@ pub fn main() -> anyhow::Result<()> {
.copied()
.collect::<PathBuf>();

let mut builder = SpirvBuilder::default();
builder.path_to_crate = Some(crate_path);
builder.target = Some("spirv-unknown-vulkan1.3".to_string());
{% if integration_type == "spirv-builder" -%}
let mut builder = SpirvBuilder::new(crate_path, "spirv-unknown-vulkan1.3");
{% endif -%}
{% if integration_type == "cargo-gpu" -%}
let install = Install::from_shader_crate(crate_path.clone()).run()?;
let mut builder = install.to_spirv_builder(crate_path, "spirv-unknown-vulkan1.3");
{% endif -%}
builder.print_metadata = MetadataPrintout::DependencyOnly;
builder.shader_panic_strategy = ShaderPanicStrategy::DebugPrintfThenExit {
print_inputs: true,
Expand Down
6 changes: 6 additions & 0 deletions ash-graphics/cargo-generate.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[template]
ignore = ["target"]
exclude = ["target"]

[placeholders]
integration_type = { prompt = "What integration type?", choices = ["cargo-gpu", "spirv-builder"], default = "cargo-gpu", type = "string" }

[conditional.'integration_type != "spirv-builder"']
ignore = [ "rust-toolchain.toml" ]
13 changes: 12 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ in with pkgs; stdenv.mkDerivation rec {
# Allow cargo to download crates (even inside `nix-shell --pure`).
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";

nativeBuildInputs = [ rustup cargo-generate ];
nativeBuildInputs = [
rustup
pkg-config
cargo-generate
];

buildInputs = [
libgit2
openssl
];

nativeCheckInputs = [ gitMinimal ];

# Runtime dependencies (for the example runners).
LD_LIBRARY_PATH = with xorg; lib.makeLibraryPath [
Expand Down
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "nightly-2025-06-30"
components = ["rust-src", "rustc-dev", "llvm-tools"]
2 changes: 2 additions & 0 deletions xtask/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run --package xtask --"
Loading
Loading