summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
diff options
context:
space:
mode:
authorameerj <aj662@drexel.edu>2020-07-28 06:08:02 +0200
committerameerj <aj662@drexel.edu>2020-08-16 18:02:22 +0200
commit6ac97405df021d5d2bd9a529253bd5c5a418c1a9 (patch)
tree0abc29657e9187bcfd3484ed7b091d0ea0f89f0f /src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
parentMerge pull request #4528 from lioncash/discard (diff)
downloadyuzu-6ac97405df021d5d2bd9a529253bd5c5a418c1a9.tar
yuzu-6ac97405df021d5d2bd9a529253bd5c5a418c1a9.tar.gz
yuzu-6ac97405df021d5d2bd9a529253bd5c5a418c1a9.tar.bz2
yuzu-6ac97405df021d5d2bd9a529253bd5c5a418c1a9.tar.lz
yuzu-6ac97405df021d5d2bd9a529253bd5c5a418c1a9.tar.xz
yuzu-6ac97405df021d5d2bd9a529253bd5c5a418c1a9.tar.zst
yuzu-6ac97405df021d5d2bd9a529253bd5c5a418c1a9.zip
Diffstat (limited to 'src/video_core/renderer_vulkan/vk_pipeline_cache.cpp')
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
index 418c62bc4..45d4dcb8c 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
@@ -205,7 +205,8 @@ std::array<Shader*, Maxwell::MaxShaderProgram> VKPipelineCache::GetShaders() {
return last_shaders = shaders;
}
-VKGraphicsPipeline& VKPipelineCache::GetGraphicsPipeline(const GraphicsPipelineCacheKey& key) {
+VKGraphicsPipeline& VKPipelineCache::GetGraphicsPipeline(
+ const GraphicsPipelineCacheKey& key, VideoCommon::Shader::AsyncShaders& async_shaders) {
MICROPROFILE_SCOPE(Vulkan_PipelineCache);
if (last_graphics_pipeline && last_graphics_key == key) {
@@ -213,11 +214,27 @@ VKGraphicsPipeline& VKPipelineCache::GetGraphicsPipeline(const GraphicsPipelineC
}
last_graphics_key = key;
+ if (device.UseAsynchronousShaders()) {
+ auto work = async_shaders.GetCompletedWork();
+ for (std::size_t i = 0; i < work.size(); ++i) {
+ auto& entry = graphics_cache.at(work[i].pipeline->GetCacheKey());
+ entry = std::move(work[i].pipeline);
+ }
+ const auto [pair, is_cache_miss] = graphics_cache.try_emplace(key);
+ if (is_cache_miss) {
+ LOG_INFO(Render_Vulkan, "Compile 0x{:016X}", key.Hash());
+ const auto [program, bindings] = DecompileShaders(key.fixed_state);
+ async_shaders.QueueVulkanShader(this, bindings, program, key.renderpass_params,
+ key.padding, key.shaders, key.fixed_state);
+ }
+ return *(last_graphics_pipeline = graphics_cache.at(key).get());
+ }
+
const auto [pair, is_cache_miss] = graphics_cache.try_emplace(key);
auto& entry = pair->second;
if (is_cache_miss) {
LOG_INFO(Render_Vulkan, "Compile 0x{:016X}", key.Hash());
- const auto [program, bindings] = DecompileShaders(key);
+ const auto [program, bindings] = DecompileShaders(key.fixed_state);
entry = std::make_unique<VKGraphicsPipeline>(device, scheduler, descriptor_pool,
update_descriptor_queue, renderpass_cache, key,
bindings, program);
@@ -312,8 +329,7 @@ void VKPipelineCache::OnShaderRemoval(Shader* shader) {
}
std::pair<SPIRVProgram, std::vector<VkDescriptorSetLayoutBinding>>
-VKPipelineCache::DecompileShaders(const GraphicsPipelineCacheKey& key) {
- const auto& fixed_state = key.fixed_state;
+VKPipelineCache::DecompileShaders(const FixedPipelineState& fixed_state) {
auto& memory_manager = system.GPU().MemoryManager();
const auto& gpu = system.GPU().Maxwell3D();