This commit is contained in:
Mars 2024-10-08 23:56:24 -04:00
parent 7762cb4712
commit 9b93436efd
Signed by: pupbrained
GPG key ID: 874E22DF2F9DFCB5
2 changed files with 40 additions and 41 deletions

View file

@ -24,19 +24,14 @@
};
};
stdenv =
if pkgs.hostPlatform.isLinux
then pkgs.stdenvAdapters.useMoldLinker pkgs.llvmPackages_18.libcxxStdenv
else pkgs.llvmPackages_18.libcxxStdenv;
stdenv = with pkgs;
if hostPlatform.isLinux
then stdenvAdapters.useMoldLinker llvmPackages_18.libcxxStdenv
else llvmPackages_18.libcxxStdenv;
sources = import ./_sources/generated.nix {
inherit (pkgs) fetchFromGitHub fetchgit fetchurl dockerTools;
};
sources = import ./_sources/generated.nix {inherit (pkgs) fetchFromGitHub fetchgit fetchurl dockerTools;};
mkPkg = name:
pkgs.${name}.overrideAttrs {
inherit (sources.${name}) pname version src;
};
mkPkg = name: pkgs.${name}.overrideAttrs {inherit (sources.${name}) pname version src;};
fmt = mkPkg "fmt";
@ -51,52 +46,53 @@
vulkan-loader
vulkan-tools
];
in
with pkgs; rec {
packages = rec {
graphics-test = stdenv.mkDerivation {
name = "graphics-test";
version = "0.1.0";
src = self;
in rec {
packages = rec {
graphics-test = stdenv.mkDerivation {
name = "graphics-test";
version = "0.1.0";
src = self;
nativeBuildInputs = [
meson
ninja
pkg-config
];
nativeBuildInputs = with pkgs; [
meson
ninja
pkg-config
];
buildInputs = deps;
buildInputs = deps;
configurePhase = ''
meson setup build
'';
configurePhase = ''
meson setup build
'';
buildPhase = ''
meson compile -C build
'';
buildPhase = ''
meson compile -C build
'';
installPhase = ''
mkdir -p $out/bin
mv build/graphics-test $out/bin/graphics-test
'';
};
default = graphics-test;
installPhase = ''
mkdir -p $out/bin
mv build/graphics-test $out/bin/graphics-test
'';
};
formatter = treefmt-nix.lib.mkWrapper pkgs {
default = graphics-test;
};
formatter = with pkgs;
treefmt-nix.lib.mkWrapper pkgs {
projectRootFile = "flake.nix";
programs = {
alejandra.enable = true;
clang-format = {
enable = true;
package = pkgs.llvmPackages_18.clang-tools;
package = llvmPackages_18.clang-tools;
};
};
};
devShell = mkShell.override {inherit stdenv;} {
devShell = with pkgs;
mkShell.override {inherit stdenv;} {
packages =
[
alejandra
@ -134,6 +130,6 @@
name = "C++";
};
}
}
);
}

View file

@ -38,6 +38,7 @@ constexpr bool enableValidationLayers = true;
class VulkanApp {
public:
fn run() -> void {
// Create a window
initWindow();
initVulkan();
mainLoop();
@ -854,11 +855,13 @@ class VulkanApp {
};
fn main() -> i32 {
// Allows for loading functions dynamically at runtime
vk::DynamicLoader dynamicLoader;
auto vkGetInstanceProcAddr =
dynamicLoader.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
// Create app object
VulkanApp app;
try {