-
-
Save f0i/2bbf5d05730a092449e8504bd163c236 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ nix-shell shell.nix | |
$ git clone https://github.com/gfx-rs/wgpu-rs | |
$ cd wgpu-rs | |
$ cargo run --example cube | |
Finished dev [unoptimized + debuginfo] target(s) in 0.07s | |
Running `target/debug/examples/cube` | |
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', examples/cube/../framework.rs:117:19 | |
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// full file: https://github.com/gfx-rs/wgpu-rs/blob/master/examples/framework.rs#L117 | |
log::info!("Initializing the surface..."); | |
let instance = wgpu::Instance::new(wgpu::BackendBit::PRIMARY); | |
let (size, surface) = unsafe { | |
let size = window.inner_size(); | |
let surface = instance.create_surface(&window); | |
(size, surface) | |
}; | |
let adapter = instance | |
.request_adapter(&wgpu::RequestAdapterOptions { | |
power_preference: wgpu::PowerPreference::Default, | |
compatible_surface: Some(&surface), | |
}) | |
.await | |
.unwrap(); | |
let optional_features = E::optional_features(); | |
let required_features = E::required_features(); | |
let adapter_features = adapter.features(); | |
assert!( | |
adapter_features.contains(required_features), | |
"Adapter does not support required features for this example: {:?}", | |
required_features - adapter_features | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
# Look here for information about how pin version of nixpkgs | |
# → https://nixos.wiki/wiki/FAQ/Pinning_Nixpkgs | |
pinnedPkgs = import (builtins.fetchGit { | |
name = "nixpkgs-20.03"; | |
url = "https://github.com/nixos/nixpkgs/"; | |
ref = "refs/heads/release-20.03"; | |
}) { }; | |
# This allows overriding pkgs by passing `--arg pkgs ...` | |
in { pkgs ? pinnedPkgs }: | |
let | |
isOsX = builtins.currentSystem == "x86_64-darwin"; | |
darwin-frameworks = | |
if isOsX then | |
with pkgs.darwin.apple_sdk.frameworks; [ | |
AppKit | |
CoreFoundation | |
CoreServices | |
CoreVideo | |
Foundation | |
Metal | |
Security | |
] | |
else | |
[ ]; | |
llvm = pkgs.llvm_10; | |
inputs = with pkgs; [ | |
rustup | |
cargo | |
llvm | |
# libraries for llvm | |
libffi | |
libxml2 | |
zlib | |
pkg-config x11 libffi libxml2 rlwrap cargo xorg.libXcursor wlroots libinput xorg.libXrandr | |
xorg.libXi | |
vulkan-tools | |
vulkan-loader | |
vulkan-headers | |
]; | |
in pkgs.mkShell { | |
buildInputs = inputs ++ darwin-frameworks; | |
LLVM_SYS_100_PREFIX = "${llvm}"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment