From 450c92ec556c157d4099975729e4697811ff3d53 Mon Sep 17 00:00:00 2001 From: pupbrained Date: Tue, 5 Nov 2024 19:47:37 -0500 Subject: [PATCH] suckel --- flake.lock | 12 ++++++------ meson.build | 1 + src/util/shaders.hpp | 14 +++++++------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/flake.lock b/flake.lock index 543d1fa..4d1396c 100644 --- a/flake.lock +++ b/flake.lock @@ -53,11 +53,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1729632202, - "narHash": "sha256-BqWFOqG9Iuzf5wm9dyVWPeH1SPxSjCxo3inUSnYqxaQ=", + "lastModified": 1730853263, + "narHash": "sha256-Cnp2zjzaA4bYUOhM/xo9GxhgOgTHn+qNbSGu4su8RaQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5a95c26209c2e136ef7da309824f562253b5fd7a", + "rev": "5d4d64e923ce570996c089d768710f61bde0b9d3", "type": "github" }, "original": { @@ -126,11 +126,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1729613947, - "narHash": "sha256-XGOvuIPW1XRfPgHtGYXd5MAmJzZtOuwlfKDgxX5KT3s=", + "lastModified": 1730321837, + "narHash": "sha256-vK+a09qq19QNu2MlLcvN4qcRctJbqWkX7ahgPZ/+maI=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "aac86347fb5063960eccb19493e0cadcdb4205ca", + "rev": "746901bb8dba96d154b66492a29f5db0693dbfcc", "type": "github" }, "original": { diff --git a/meson.build b/meson.build index 5c2faff..3fddbaa 100644 --- a/meson.build +++ b/meson.build @@ -14,6 +14,7 @@ common_cpp_args = [ '-Wno-c++98-compat-pedantic', '-Wno-pre-c++20-compat-pedantic', '-Wno-padded', + '-mavx2' ] add_project_arguments(cpp.get_supported_arguments(common_cpp_args), language: 'cpp') diff --git a/src/util/shaders.hpp b/src/util/shaders.hpp index f48acaf..3c33dbe 100644 --- a/src/util/shaders.hpp +++ b/src/util/shaders.hpp @@ -33,13 +33,13 @@ class ShaderCompiler { ) -> std::vector { using namespace std; - const string cacheFile = getCacheFilePath(shaderName); + const filesystem::path cacheFile = getCacheFilePath(shaderName); // Try loading from cache first vector spirvCode = loadCachedShader(cacheFile); if (!spirvCode.empty()) { - fmt::println("Loaded shader from cache: {}", cacheFile); + fmt::println("Loaded shader from cache: {}", cacheFile.string()); return spirvCode; } @@ -64,7 +64,7 @@ class ShaderCompiler { * This function determines the appropriate directory for caching shaders * based on the operating system and returns the full path for the specified shader name. */ - static fn getCacheFilePath(const string& shaderName) -> string { + static fn getCacheFilePath(const string& shaderName) -> std::filesystem::path { using namespace std::filesystem; #ifdef _WIN32 @@ -78,7 +78,7 @@ class ShaderCompiler { if (!exists(cacheDir)) create_directories(cacheDir); // Create the directory if it doesn't exist - return (cacheDir / (shaderName + ".spv")).string(); + return cacheDir / (shaderName + ".spv"); } /** @@ -117,7 +117,7 @@ class ShaderCompiler { * This function checks if the specified cache file exists and reads its * contents into a vector. If the file cannot be opened, an exception is thrown. */ - static fn loadCachedShader(const string& cacheFile) -> std::vector { + static fn loadCachedShader(const std::filesystem::path& cacheFile) -> std::vector { using namespace std; if (!filesystem::exists(cacheFile)) @@ -127,14 +127,14 @@ class ShaderCompiler { // Check if the file was successfully opened if (!file) - throw runtime_error("Failed to open cached shader file: " + cacheFile); + throw runtime_error("Failed to open cached shader file: " + cacheFile.string()); usize fileSize = filesystem::file_size(cacheFile); vector spirvCode(fileSize / sizeof(u32)); // Read entire file content into the vector if (!file.read(bit_cast(spirvCode.data()), static_cast(fileSize))) - throw runtime_error("Failed to read cached shader file: " + cacheFile); + throw runtime_error("Failed to read cached shader file: " + cacheFile.string()); return spirvCode; }