mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-23 18:30:46 +00:00
Vulkan: Load shaders/pipelines on thread.
In case it's slow when not reading raw cache data.
This commit is contained in:
parent
99af1d58ad
commit
7ae4a9e977
@ -16,6 +16,7 @@
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include <thread>
|
||||
#include "base/logging.h"
|
||||
#include "profiler/profiler.h"
|
||||
|
||||
@ -101,11 +102,20 @@ GPU_Vulkan::GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
||||
if (discID.size()) {
|
||||
File::CreateFullPath(GetSysDirectory(DIRECTORY_APP_CACHE));
|
||||
shaderCachePath_ = GetSysDirectory(DIRECTORY_APP_CACHE) + "/" + discID + ".vkshadercache";
|
||||
shaderCacheLoaded_ = false;
|
||||
|
||||
LoadCache(shaderCachePath_);
|
||||
std::thread th([&] {
|
||||
LoadCache(shaderCachePath_);
|
||||
shaderCacheLoaded_ = true;
|
||||
});
|
||||
th.detach();
|
||||
}
|
||||
}
|
||||
|
||||
bool GPU_Vulkan::IsReady() {
|
||||
return shaderCacheLoaded_;
|
||||
}
|
||||
|
||||
void GPU_Vulkan::LoadCache(std::string filename) {
|
||||
PSP_SetLoading("Loading shader cache...");
|
||||
// Actually precompiled by IsReady() since we're single-threaded.
|
||||
|
@ -38,6 +38,8 @@ public:
|
||||
// This gets called on startup and when we get back from settings.
|
||||
void CheckGPUFeatures() override;
|
||||
|
||||
bool IsReady() override;
|
||||
|
||||
// These are where we can reset command buffers etc.
|
||||
void BeginHostFrame() override;
|
||||
void EndHostFrame() override;
|
||||
@ -105,4 +107,5 @@ private:
|
||||
FrameData frameData_[VulkanContext::MAX_INFLIGHT_FRAMES]{};
|
||||
|
||||
std::string shaderCachePath_;
|
||||
bool shaderCacheLoaded_ = false;
|
||||
};
|
||||
|
@ -602,12 +602,12 @@ bool PipelineManagerVulkan::LoadCache(FILE *file, bool loadRawPipelineCache, Sha
|
||||
} else {
|
||||
vkMergePipelineCaches(vulkan_->GetDevice(), pipelineCache_, 1, &cache);
|
||||
}
|
||||
NOTICE_LOG(G3D, "Loaded Vulkan pipeline cache (%d bytes).", (int)size);
|
||||
} else {
|
||||
if (!pipelineCache_) {
|
||||
VkPipelineCacheCreateInfo pc{ VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO };
|
||||
VkResult res = vkCreatePipelineCache(vulkan_->GetDevice(), &pc, nullptr, &pipelineCache_);
|
||||
}
|
||||
NOTICE_LOG(G3D, "Loaded Vulkan pipeline cache (%d bytes).", (int)size);
|
||||
}
|
||||
|
||||
// Read the number of pipelines.
|
||||
|
Loading…
x
Reference in New Issue
Block a user