mirror of https://github.com/snes9xgit/snes9x.git
Vulkan/Slang: Load shader files asynchronously.
This commit is contained in:
parent
54770ef3cc
commit
8e38e14ea9
|
@ -11,6 +11,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <future>
|
||||||
#include "../external/SPIRV-Cross/spirv_cross.hpp"
|
#include "../external/SPIRV-Cross/spirv_cross.hpp"
|
||||||
#include "../external/SPIRV-Cross/spirv_glsl.hpp"
|
#include "../external/SPIRV-Cross/spirv_glsl.hpp"
|
||||||
#include "slang_shader.hpp"
|
#include "slang_shader.hpp"
|
||||||
|
@ -109,12 +110,19 @@ bool SlangPreset::load_preset_file(string filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &shader : passes)
|
std::vector<std::future<bool>> futures;
|
||||||
|
for (size_t i = 0; i < passes.size(); i++)
|
||||||
{
|
{
|
||||||
if (!shader.load_file())
|
futures.push_back(std::async(std::launch::async, [&, i]() -> bool {
|
||||||
return false;
|
return passes[i].load_file();
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
bool success = true;
|
||||||
|
for (auto &f : futures)
|
||||||
|
success &= f.get();
|
||||||
|
if (!success)
|
||||||
|
return false;
|
||||||
|
|
||||||
gather_parameters();
|
gather_parameters();
|
||||||
|
|
||||||
for (auto &p : parameters)
|
for (auto &p : parameters)
|
||||||
|
|
Loading…
Reference in New Issue