forked from pupbrained/vulkan-test
suckel
This commit is contained in:
parent
0f7c86bd4b
commit
450c92ec55
12
flake.lock
12
flake.lock
|
@ -53,11 +53,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1729632202,
|
"lastModified": 1730853263,
|
||||||
"narHash": "sha256-BqWFOqG9Iuzf5wm9dyVWPeH1SPxSjCxo3inUSnYqxaQ=",
|
"narHash": "sha256-Cnp2zjzaA4bYUOhM/xo9GxhgOgTHn+qNbSGu4su8RaQ=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "5a95c26209c2e136ef7da309824f562253b5fd7a",
|
"rev": "5d4d64e923ce570996c089d768710f61bde0b9d3",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -126,11 +126,11 @@
|
||||||
"nixpkgs": "nixpkgs_3"
|
"nixpkgs": "nixpkgs_3"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1729613947,
|
"lastModified": 1730321837,
|
||||||
"narHash": "sha256-XGOvuIPW1XRfPgHtGYXd5MAmJzZtOuwlfKDgxX5KT3s=",
|
"narHash": "sha256-vK+a09qq19QNu2MlLcvN4qcRctJbqWkX7ahgPZ/+maI=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "treefmt-nix",
|
"repo": "treefmt-nix",
|
||||||
"rev": "aac86347fb5063960eccb19493e0cadcdb4205ca",
|
"rev": "746901bb8dba96d154b66492a29f5db0693dbfcc",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -14,6 +14,7 @@ common_cpp_args = [
|
||||||
'-Wno-c++98-compat-pedantic',
|
'-Wno-c++98-compat-pedantic',
|
||||||
'-Wno-pre-c++20-compat-pedantic',
|
'-Wno-pre-c++20-compat-pedantic',
|
||||||
'-Wno-padded',
|
'-Wno-padded',
|
||||||
|
'-mavx2'
|
||||||
]
|
]
|
||||||
|
|
||||||
add_project_arguments(cpp.get_supported_arguments(common_cpp_args), language: 'cpp')
|
add_project_arguments(cpp.get_supported_arguments(common_cpp_args), language: 'cpp')
|
||||||
|
|
|
@ -33,13 +33,13 @@ class ShaderCompiler {
|
||||||
) -> std::vector<u32> {
|
) -> std::vector<u32> {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const string cacheFile = getCacheFilePath(shaderName);
|
const filesystem::path cacheFile = getCacheFilePath(shaderName);
|
||||||
|
|
||||||
// Try loading from cache first
|
// Try loading from cache first
|
||||||
vector<u32> spirvCode = loadCachedShader(cacheFile);
|
vector<u32> spirvCode = loadCachedShader(cacheFile);
|
||||||
|
|
||||||
if (!spirvCode.empty()) {
|
if (!spirvCode.empty()) {
|
||||||
fmt::println("Loaded shader from cache: {}", cacheFile);
|
fmt::println("Loaded shader from cache: {}", cacheFile.string());
|
||||||
return spirvCode;
|
return spirvCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ class ShaderCompiler {
|
||||||
* This function determines the appropriate directory for caching shaders
|
* This function determines the appropriate directory for caching shaders
|
||||||
* based on the operating system and returns the full path for the specified shader name.
|
* 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;
|
using namespace std::filesystem;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -78,7 +78,7 @@ class ShaderCompiler {
|
||||||
if (!exists(cacheDir))
|
if (!exists(cacheDir))
|
||||||
create_directories(cacheDir); // Create the directory if it doesn't exist
|
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
|
* 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.
|
* contents into a vector. If the file cannot be opened, an exception is thrown.
|
||||||
*/
|
*/
|
||||||
static fn loadCachedShader(const string& cacheFile) -> std::vector<u32> {
|
static fn loadCachedShader(const std::filesystem::path& cacheFile) -> std::vector<u32> {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
if (!filesystem::exists(cacheFile))
|
if (!filesystem::exists(cacheFile))
|
||||||
|
@ -127,14 +127,14 @@ class ShaderCompiler {
|
||||||
|
|
||||||
// Check if the file was successfully opened
|
// Check if the file was successfully opened
|
||||||
if (!file)
|
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);
|
usize fileSize = filesystem::file_size(cacheFile);
|
||||||
vector<u32> spirvCode(fileSize / sizeof(u32));
|
vector<u32> spirvCode(fileSize / sizeof(u32));
|
||||||
|
|
||||||
// Read entire file content into the vector
|
// Read entire file content into the vector
|
||||||
if (!file.read(bit_cast<char*>(spirvCode.data()), static_cast<streamsize>(fileSize)))
|
if (!file.read(bit_cast<char*>(spirvCode.data()), static_cast<streamsize>(fileSize)))
|
||||||
throw runtime_error("Failed to read cached shader file: " + cacheFile);
|
throw runtime_error("Failed to read cached shader file: " + cacheFile.string());
|
||||||
|
|
||||||
return spirvCode;
|
return spirvCode;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue