summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-06-06 05:11:36 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:35 +0200
commitcffd4716c5ebf9b93505b5bfa96d9b407f349336 (patch)
treee94c3daa5420fc066695b1082b0f0af60c5cb555 /src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
parentvk_pipeline_cache: Add asynchronous shaders (diff)
downloadyuzu-cffd4716c5ebf9b93505b5bfa96d9b407f349336.tar
yuzu-cffd4716c5ebf9b93505b5bfa96d9b407f349336.tar.gz
yuzu-cffd4716c5ebf9b93505b5bfa96d9b407f349336.tar.bz2
yuzu-cffd4716c5ebf9b93505b5bfa96d9b407f349336.tar.lz
yuzu-cffd4716c5ebf9b93505b5bfa96d9b407f349336.tar.xz
yuzu-cffd4716c5ebf9b93505b5bfa96d9b407f349336.tar.zst
yuzu-cffd4716c5ebf9b93505b5bfa96d9b407f349336.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.cpp50
1 files changed, 29 insertions, 21 deletions
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
index 741ed1a98..e61d76490 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
@@ -235,11 +235,11 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, Tegra::Engines::Maxw
VKScheduler& scheduler_, DescriptorPool& descriptor_pool_,
VKUpdateDescriptorQueue& update_descriptor_queue_,
RenderPassCache& render_pass_cache_, BufferCache& buffer_cache_,
- TextureCache& texture_cache_)
+ TextureCache& texture_cache_, VideoCore::ShaderNotify& shader_notify_)
: VideoCommon::ShaderCache{rasterizer_, gpu_memory_, maxwell3d_, kepler_compute_},
device{device_}, scheduler{scheduler_}, descriptor_pool{descriptor_pool_},
update_descriptor_queue{update_descriptor_queue_}, render_pass_cache{render_pass_cache_},
- buffer_cache{buffer_cache_}, texture_cache{texture_cache_},
+ buffer_cache{buffer_cache_}, texture_cache{texture_cache_}, shader_notify{shader_notify_},
use_asynchronous_shaders{Settings::values.use_asynchronous_shaders.GetValue()},
workers(std::max(std::thread::hardware_concurrency(), 2U) - 1, "yuzu:PipelineBuilder"),
serialization_thread(1, "yuzu:PipelineSerialization") {
@@ -307,19 +307,7 @@ GraphicsPipeline* PipelineCache::CurrentGraphicsPipeline() {
return BuiltPipeline(current_pipeline);
}
}
- const auto [pair, is_new]{graphics_cache.try_emplace(graphics_key)};
- auto& pipeline{pair->second};
- if (is_new) {
- pipeline = CreateGraphicsPipeline();
- }
- if (!pipeline) {
- return nullptr;
- }
- if (current_pipeline) {
- current_pipeline->AddTransition(pipeline.get());
- }
- current_pipeline = pipeline.get();
- return BuiltPipeline(current_pipeline);
+ return CurrentGraphicsPipelineSlowPath();
}
ComputePipeline* PipelineCache::CurrentComputePipeline() {
@@ -416,6 +404,22 @@ void PipelineCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading
workers.WaitForRequests();
}
+GraphicsPipeline* PipelineCache::CurrentGraphicsPipelineSlowPath() {
+ const auto [pair, is_new]{graphics_cache.try_emplace(graphics_key)};
+ auto& pipeline{pair->second};
+ if (is_new) {
+ pipeline = CreateGraphicsPipeline();
+ }
+ if (!pipeline) {
+ return nullptr;
+ }
+ if (current_pipeline) {
+ current_pipeline->AddTransition(pipeline.get());
+ }
+ current_pipeline = pipeline.get();
+ return BuiltPipeline(current_pipeline);
+}
+
GraphicsPipeline* PipelineCache::BuiltPipeline(GraphicsPipeline* pipeline) const noexcept {
if (pipeline->IsBuilt()) {
return pipeline;
@@ -484,14 +488,16 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline(
device.SaveShader(code);
modules[stage_index] = BuildShader(device, code);
if (device.HasDebuggingToolAttached()) {
- const std::string name{fmt::format("{:016x}", key.unique_hashes[index])};
+ const std::string name{fmt::format("Shader {:016x}", key.unique_hashes[index])};
modules[stage_index].SetObjectNameEXT(name.c_str());
}
}
Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr};
- return std::make_unique<GraphicsPipeline>(
- maxwell3d, gpu_memory, scheduler, buffer_cache, texture_cache, device, descriptor_pool,
- update_descriptor_queue, thread_worker, render_pass_cache, key, std::move(modules), infos);
+ VideoCore::ShaderNotify* const notify{build_in_parallel ? &shader_notify : nullptr};
+ return std::make_unique<GraphicsPipeline>(maxwell3d, gpu_memory, scheduler, buffer_cache,
+ texture_cache, notify, device, descriptor_pool,
+ update_descriptor_queue, thread_worker,
+ render_pass_cache, key, std::move(modules), infos);
} catch (const Shader::Exception& exception) {
LOG_ERROR(Render_Vulkan, "{}", exception.what());
@@ -550,12 +556,14 @@ std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline(
device.SaveShader(code);
vk::ShaderModule spv_module{BuildShader(device, code)};
if (device.HasDebuggingToolAttached()) {
- const auto name{fmt::format("{:016x}", key.unique_hash)};
+ const auto name{fmt::format("Shader {:016x}", key.unique_hash)};
spv_module.SetObjectNameEXT(name.c_str());
}
Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr};
+ VideoCore::ShaderNotify* const notify{build_in_parallel ? &shader_notify : nullptr};
return std::make_unique<ComputePipeline>(device, descriptor_pool, update_descriptor_queue,
- thread_worker, program.info, std::move(spv_module));
+ thread_worker, notify, program.info,
+ std::move(spv_module));
} catch (const Shader::Exception& exception) {
LOG_ERROR(Render_Vulkan, "{}", exception.what());