Skip to content

Commit

Permalink
make it possible to set gpu backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Kl4rry committed Apr 17, 2024
1 parent a8c5549 commit ae65fb9
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 80 deletions.
84 changes: 42 additions & 42 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,45 +185,45 @@ jobs:
name: windows-build-artifacts
path: target/release/fe.exe

build-mac:
runs-on: macos-latest

steps:
- uses: actions/checkout@v1

- name: Cache Cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-stable-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-stable-cargo-registry-
- name: Cache Cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-stable-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-stable-cargo-index-
- name: Cache Cargo build
uses: actions/cache@v1
with:
path: target/debug
key: ${{ runner.os }}-stable-debug-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-stable-debug-target-
- name: Install Rust
run: |
rustup update ${{ matrix.rust }} --no-self-update
rustup default ${{ matrix.rust }}
- name: Build
run: cargo build --release

- name: Upload build artifacts
uses: actions/upload-artifact@v1
with:
name: macos-build-artifacts
path: target/release/fe
# build-mac:
# runs-on: macos-latest
#
# steps:
# - uses: actions/checkout@v1
#
# - name: Cache Cargo registry
# uses: actions/cache@v1
# with:
# path: ~/.cargo/registry
# key: ${{ runner.os }}-stable-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
# restore-keys: |
# ${{ runner.os }}-stable-cargo-registry-
#
# - name: Cache Cargo index
# uses: actions/cache@v1
# with:
# path: ~/.cargo/git
# key: ${{ runner.os }}-stable-cargo-index-${{ hashFiles('**/Cargo.lock') }}
# restore-keys: |
# ${{ runner.os }}-stable-cargo-index-
#
# - name: Cache Cargo build
# uses: actions/cache@v1
# with:
# path: target/debug
# key: ${{ runner.os }}-stable-debug-target-${{ hashFiles('**/Cargo.lock') }}
# restore-keys: |
# ${{ runner.os }}-stable-debug-target-
#
# - name: Install Rust
# run: |
# rustup update ${{ matrix.rust }} --no-self-update
# rustup default ${{ matrix.rust }}
# - name: Build
# run: cargo build --release
#
# - name: Upload build artifacts
# uses: actions/upload-artifact@v1
# with:
# name: macos-build-artifacts
# path: target/release/fe
63 changes: 32 additions & 31 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions crates/ferrite-gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ edition = "2021"

[dependencies]
anyhow = { workspace = true }
cgmath = "0.18.0"
ferrite-cli = { workspace = true }
ferrite-core = { workspace = true }
glyphon = "0.5.0"
pollster = "0.3.0"
tracing = { workspace = true }
wgpu = "0.19.3"
winit = "0.29.15"
glyphon = "0.5.0"
cgmath = "0.18.0"
27 changes: 22 additions & 5 deletions crates/ferrite-gui/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{iter, sync::Arc, time::Instant};
use std::{env, iter, sync::Arc, time::Instant};

use anyhow::Result;
use event_loop_wrapper::EventLoopProxyWrapper;
Expand Down Expand Up @@ -61,14 +61,31 @@ impl GuiApp {
);
let size = window.inner_size();

let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
let mut backends = if cfg!(windows) {
wgpu::Backends::DX12
} else if cfg!(macos) {
wgpu::Backends::PRIMARY
} else {
wgpu::Backends::all()
};

if let Ok(gpu_backend) = env::var("FERRITE_GPU_BACKEND") {
backends = wgpu::util::parse_backends_from_comma_list(&gpu_backend);
} else if let Ok(gpu_backend) = env::var("WGPU_BACKEND") {
backends = wgpu::util::parse_backends_from_comma_list(&gpu_backend);
};

let instance_descriptor = wgpu::InstanceDescriptor {
backends,
..Default::default()
});
};

let instance = wgpu::Instance::new(instance_descriptor);

let surface = instance.create_surface(window.clone()).unwrap();
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::HighPerformance,
power_preference: wgpu::PowerPreference::None,
compatible_surface: Some(&surface),
force_fallback_adapter: false,
})
Expand Down

0 comments on commit ae65fb9

Please sign in to comment.