lr dx11: fix exit crash. Save shader cache where vk cache is

This commit is contained in:
flyinghead 2021-12-14 16:48:23 +01:00
parent 4d60150345
commit 2478b72a3e
7 changed files with 13 additions and 11 deletions

View File

@ -121,9 +121,9 @@ std::string getSavestatePath(int index, bool writable)
return get_readonly_data_path(state_file); return get_readonly_data_path(state_file);
} }
std::string getVulkanCachePath() std::string getShaderCachePath(const std::string& filename)
{ {
return get_writable_data_path("vulkan_pipeline.cache"); return get_writable_data_path(filename);
} }
std::string getTextureLoadPath(const std::string& gameId) std::string getTextureLoadPath(const std::string& gameId)

View File

@ -43,7 +43,7 @@ namespace hostfs
std::string getTextureLoadPath(const std::string& gameId); std::string getTextureLoadPath(const std::string& gameId);
std::string getTextureDumpPath(); std::string getTextureDumpPath();
std::string getVulkanCachePath(); std::string getShaderCachePath(const std::string& filename);
std::string getBiosFontPath(); std::string getBiosFontPath();
} }

View File

@ -564,7 +564,7 @@ void CachedDX11Shaders::saveCache(const std::string& filename)
{ {
if (!enabled) if (!enabled)
return; return;
std::string path = get_writable_data_path(filename); std::string path = hostfs::getShaderCachePath(filename);
FILE *fp = nowide::fopen(path.c_str(), "wb"); FILE *fp = nowide::fopen(path.c_str(), "wb");
if (fp == nullptr) if (fp == nullptr)
{ {
@ -589,7 +589,7 @@ void CachedDX11Shaders::loadCache(const std::string& filename)
{ {
if (!enabled) if (!enabled)
return; return;
std::string path = get_writable_data_path(filename); std::string path = hostfs::getShaderCachePath(filename);
FILE *fp = nowide::fopen(path.c_str(), "rb"); FILE *fp = nowide::fopen(path.c_str(), "rb");
if (fp != nullptr) if (fp != nullptr)
{ {

View File

@ -25,7 +25,9 @@ DX11Context theDX11Context;
bool DX11Context::init(ID3D11Device *device, ID3D11DeviceContext *deviceContext, pD3DCompile D3DCompile, D3D_FEATURE_LEVEL featureLevel) bool DX11Context::init(ID3D11Device *device, ID3D11DeviceContext *deviceContext, pD3DCompile D3DCompile, D3D_FEATURE_LEVEL featureLevel)
{ {
NOTICE_LOG(RENDERER, "DX11 Context initializing"); NOTICE_LOG(RENDERER, "DX11 Context initializing");
device->AddRef();
pDevice.reset(device); pDevice.reset(device);
deviceContext->AddRef();
pDeviceContext.reset(deviceContext); pDeviceContext.reset(deviceContext);
this->D3DCompile = D3DCompile; this->D3DCompile = D3DCompile;
this->featureLevel = featureLevel; this->featureLevel = featureLevel;

View File

@ -251,7 +251,7 @@ bool VulkanContext::init(retro_hw_render_interface_vulkan *retro_render_if)
descriptorPool = device.createDescriptorPoolUnique(vk::DescriptorPoolCreateInfo(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet, descriptorPool = device.createDescriptorPoolUnique(vk::DescriptorPoolCreateInfo(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet,
10000, ARRAY_SIZE(pool_sizes), pool_sizes)); 10000, ARRAY_SIZE(pool_sizes), pool_sizes));
std::string cachePath = hostfs::getVulkanCachePath(); std::string cachePath = hostfs::getShaderCachePath("vulkan_pipeline.cache");
FILE *f = fopen(cachePath.c_str(), "rb"); FILE *f = fopen(cachePath.c_str(), "rb");
if (f == nullptr) if (f == nullptr)
pipelineCache = device.createPipelineCacheUnique(vk::PipelineCacheCreateInfo()); pipelineCache = device.createPipelineCacheUnique(vk::PipelineCacheCreateInfo());
@ -307,7 +307,7 @@ void VulkanContext::term()
std::vector<u8> cacheData = device.getPipelineCacheData(*pipelineCache); std::vector<u8> cacheData = device.getPipelineCacheData(*pipelineCache);
if (!cacheData.empty()) if (!cacheData.empty())
{ {
std::string cachePath = hostfs::getVulkanCachePath(); std::string cachePath = hostfs::getShaderCachePath("vulkan_pipeline.cache");
FILE *f = fopen(cachePath.c_str(), "wb"); FILE *f = fopen(cachePath.c_str(), "wb");
if (f != nullptr) if (f != nullptr)
{ {

View File

@ -446,7 +446,7 @@ bool VulkanContext::InitDevice()
10000, ARRAY_SIZE(pool_sizes), pool_sizes)); 10000, ARRAY_SIZE(pool_sizes), pool_sizes));
std::string cachePath = hostfs::getVulkanCachePath(); std::string cachePath = hostfs::getShaderCachePath("vulkan_pipeline.cache");
FILE *f = nowide::fopen(cachePath.c_str(), "rb"); FILE *f = nowide::fopen(cachePath.c_str(), "rb");
if (f == nullptr) if (f == nullptr)
pipelineCache = device->createPipelineCacheUnique(vk::PipelineCacheCreateInfo()); pipelineCache = device->createPipelineCacheUnique(vk::PipelineCacheCreateInfo());
@ -940,7 +940,7 @@ void VulkanContext::term()
std::vector<u8> cacheData = device->getPipelineCacheData(*pipelineCache); std::vector<u8> cacheData = device->getPipelineCacheData(*pipelineCache);
if (!cacheData.empty()) if (!cacheData.empty())
{ {
std::string cachePath = hostfs::getVulkanCachePath(); std::string cachePath = hostfs::getShaderCachePath("vulkan_pipeline.cache");
FILE *f = nowide::fopen(cachePath.c_str(), "wb"); FILE *f = nowide::fopen(cachePath.c_str(), "wb");
if (f != nullptr) if (f != nullptr)
{ {

View File

@ -107,9 +107,9 @@ std::string getSavestatePath(int index, bool writable)
return ""; return "";
} }
std::string getVulkanCachePath() std::string getShaderCachePath(const std::string& filename)
{ {
return std::string(game_dir_no_slash) + std::string(path_default_slash()) + "vulkan_pipeline.cache"; return std::string(game_dir_no_slash) + std::string(path_default_slash()) + filename;
} }
std::string getTextureLoadPath(const std::string& gameId) std::string getTextureLoadPath(const std::string& gameId)