From 2478b72a3e5fb8c2f5d16ce63e623931c61e66d5 Mon Sep 17 00:00:00 2001 From: flyinghead Date: Tue, 14 Dec 2021 16:48:23 +0100 Subject: [PATCH] lr dx11: fix exit crash. Save shader cache where vk cache is --- core/oslib/oslib.cpp | 4 ++-- core/oslib/oslib.h | 2 +- core/rend/dx11/dx11_shaders.cpp | 4 ++-- core/rend/dx11/dx11context_lr.cpp | 2 ++ core/rend/vulkan/vk_context_lr.cpp | 4 ++-- core/rend/vulkan/vulkan_context.cpp | 4 ++-- shell/libretro/oslib.cpp | 4 ++-- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/core/oslib/oslib.cpp b/core/oslib/oslib.cpp index b720e8945..e20267743 100644 --- a/core/oslib/oslib.cpp +++ b/core/oslib/oslib.cpp @@ -121,9 +121,9 @@ std::string getSavestatePath(int index, bool writable) 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) diff --git a/core/oslib/oslib.h b/core/oslib/oslib.h index 1a1ec5a45..7150f13c4 100644 --- a/core/oslib/oslib.h +++ b/core/oslib/oslib.h @@ -43,7 +43,7 @@ namespace hostfs std::string getTextureLoadPath(const std::string& gameId); std::string getTextureDumpPath(); - std::string getVulkanCachePath(); + std::string getShaderCachePath(const std::string& filename); std::string getBiosFontPath(); } diff --git a/core/rend/dx11/dx11_shaders.cpp b/core/rend/dx11/dx11_shaders.cpp index f85a0eb52..6d041f694 100644 --- a/core/rend/dx11/dx11_shaders.cpp +++ b/core/rend/dx11/dx11_shaders.cpp @@ -564,7 +564,7 @@ void CachedDX11Shaders::saveCache(const std::string& filename) { if (!enabled) return; - std::string path = get_writable_data_path(filename); + std::string path = hostfs::getShaderCachePath(filename); FILE *fp = nowide::fopen(path.c_str(), "wb"); if (fp == nullptr) { @@ -589,7 +589,7 @@ void CachedDX11Shaders::loadCache(const std::string& filename) { if (!enabled) return; - std::string path = get_writable_data_path(filename); + std::string path = hostfs::getShaderCachePath(filename); FILE *fp = nowide::fopen(path.c_str(), "rb"); if (fp != nullptr) { diff --git a/core/rend/dx11/dx11context_lr.cpp b/core/rend/dx11/dx11context_lr.cpp index fd6fba82d..efb1f9fc7 100644 --- a/core/rend/dx11/dx11context_lr.cpp +++ b/core/rend/dx11/dx11context_lr.cpp @@ -25,7 +25,9 @@ DX11Context theDX11Context; bool DX11Context::init(ID3D11Device *device, ID3D11DeviceContext *deviceContext, pD3DCompile D3DCompile, D3D_FEATURE_LEVEL featureLevel) { NOTICE_LOG(RENDERER, "DX11 Context initializing"); + device->AddRef(); pDevice.reset(device); + deviceContext->AddRef(); pDeviceContext.reset(deviceContext); this->D3DCompile = D3DCompile; this->featureLevel = featureLevel; diff --git a/core/rend/vulkan/vk_context_lr.cpp b/core/rend/vulkan/vk_context_lr.cpp index bdda3433c..bcd0c95ee 100644 --- a/core/rend/vulkan/vk_context_lr.cpp +++ b/core/rend/vulkan/vk_context_lr.cpp @@ -251,7 +251,7 @@ bool VulkanContext::init(retro_hw_render_interface_vulkan *retro_render_if) descriptorPool = device.createDescriptorPoolUnique(vk::DescriptorPoolCreateInfo(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet, 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"); if (f == nullptr) pipelineCache = device.createPipelineCacheUnique(vk::PipelineCacheCreateInfo()); @@ -307,7 +307,7 @@ void VulkanContext::term() std::vector cacheData = device.getPipelineCacheData(*pipelineCache); if (!cacheData.empty()) { - std::string cachePath = hostfs::getVulkanCachePath(); + std::string cachePath = hostfs::getShaderCachePath("vulkan_pipeline.cache"); FILE *f = fopen(cachePath.c_str(), "wb"); if (f != nullptr) { diff --git a/core/rend/vulkan/vulkan_context.cpp b/core/rend/vulkan/vulkan_context.cpp index 2fd078aa4..f5f907446 100644 --- a/core/rend/vulkan/vulkan_context.cpp +++ b/core/rend/vulkan/vulkan_context.cpp @@ -446,7 +446,7 @@ bool VulkanContext::InitDevice() 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"); if (f == nullptr) pipelineCache = device->createPipelineCacheUnique(vk::PipelineCacheCreateInfo()); @@ -940,7 +940,7 @@ void VulkanContext::term() std::vector cacheData = device->getPipelineCacheData(*pipelineCache); if (!cacheData.empty()) { - std::string cachePath = hostfs::getVulkanCachePath(); + std::string cachePath = hostfs::getShaderCachePath("vulkan_pipeline.cache"); FILE *f = nowide::fopen(cachePath.c_str(), "wb"); if (f != nullptr) { diff --git a/shell/libretro/oslib.cpp b/shell/libretro/oslib.cpp index 76df009b9..9ebd745a5 100644 --- a/shell/libretro/oslib.cpp +++ b/shell/libretro/oslib.cpp @@ -107,9 +107,9 @@ std::string getSavestatePath(int index, bool writable) 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)