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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Firestar99
144 changes: 144 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
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 ]
integration: [ "cargo-gpu", "spirv-builder" ]
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
- if: ${{ runner.os == 'Windows' && matrix.integration == 'spirv-builder' }}
name: Windows - set rustflags to make it compile
run: echo "RUSTFLAGS=-Zshare-generics=off" >> "$GITHUB_ENV"
# 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 ${{ matrix.integration }}
# no --locked, templates need to generate their lockfile
- name: cargo fetch
run: cargo xtask generate ${{ matrix.integration }} -x "cargo fetch --target $TARGET"
- name: cargo build
run: cargo xtask generate ${{ matrix.integration }} -x "cargo build"
# graphics templates have no tests by default
- name: cargo test
run: cargo xtask generate ${{ matrix.integration }} -x "cargo nextest run --no-tests warn"

# 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, xtask-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 & lint
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: Install rustup components
run: rustup component add rustfmt clippy
- 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
strategy:
fail-fast: false
matrix:
integration: [ "cargo-gpu", "spirv-builder" ]
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: Install rustup components
run: rustup component add rustfmt clippy
- 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 ${{ matrix.integration }}
# no --locked, templates need to generate their lockfile
- name: cargo fetch
run: cargo xtask generate ${{ matrix.integration }} -x "cargo fetch"
- name: fmt
run: cargo xtask generate ${{ matrix.integration }} -x "cargo fmt --all -- --check"
- name: clippy
run: cargo xtask generate ${{ matrix.integration }} -x "cargo clippy --all-targets -- -D warnings"

defaults:
run:
shell: bash
29 changes: 29 additions & 0 deletions ash-graphics/Cargo.toml.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,32 @@ raw-window-handle = "0.6.2"
winit = "0.30.0"
cfg-if = "1.0.0"
anyhow = "1.0.98"

{% if integration_type == "spirv-builder" -%}
# Optimize build scripts, copied from rust-gpu's repo
# Enable incremental by default in release mode.
[profile.release]
incremental = true
# HACK(eddyb) this is the default but without explicitly specifying it, Cargo
# will treat the identical settings in `[profile.release.build-override]` below
# as different sets of `rustc` flags and will not reuse artifacts between them.
codegen-units = 256

# Compile build-dependencies in release mode with the same settings
# as regular dependencies (including the incremental enabled above).
[profile.release.build-override]
opt-level = 3
incremental = true
codegen-units = 256

# HACK(eddyb) reduce the number of linker exports and/or imports, by avoiding
# inter-CGU linkage, to stay under the 64Ki MSVC limit for `rustc_codegen_spirv`
# when building it in "debug mode" (only relevant to CI for now, realistically),
# i.e. working around this issue: https://github.com/rust-lang/rust/issues/53014.
[profile.dev]
# HACK(eddyb) fewer inter-crate exports/imports (not just inter-CGU), but sadly
# not configurable w/o breaking `Cargo.toml` parsing from non-nightly Cargo.
#
# rustflags = ["-Zshare-generics=off"]
codegen-units = 1
{% endif -%}
10 changes: 4 additions & 6 deletions ash-graphics/ash-graphics/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,17 @@ pub fn main() -> anyhow::Result<()> {
WindowEvent::KeyboardInput {
event:
winit::event::KeyEvent {
logical_key: winit::keyboard::Key::Named(key),
logical_key:
winit::keyboard::Key::Named(winit::keyboard::NamedKey::Escape),
state: winit::event::ElementState::Pressed,
..
},
..
} => match key {
winit::keyboard::NamedKey::Escape => event_loop_window_target.exit(),
_ => {}
},
}
| WindowEvent::CloseRequested => event_loop_window_target.exit(),
WindowEvent::Resized(_) => {
swapchain.should_recreate();
}
WindowEvent::CloseRequested => event_loop_window_target.exit(),
_ => {}
}

Expand Down