summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-04-04 02:41:49 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:26 +0200
commit5ed68e83db39e1f6790a625529f10f4e1d5a8f89 (patch)
tree4931f4501e9127244eb3faddd5d475cd1c7d176f /src/video_core
parentshader: Remove unused header in VOTE (diff)
downloadyuzu-5ed68e83db39e1f6790a625529f10f4e1d5a8f89.tar
yuzu-5ed68e83db39e1f6790a625529f10f4e1d5a8f89.tar.gz
yuzu-5ed68e83db39e1f6790a625529f10f4e1d5a8f89.tar.bz2
yuzu-5ed68e83db39e1f6790a625529f10f4e1d5a8f89.tar.lz
yuzu-5ed68e83db39e1f6790a625529f10f4e1d5a8f89.tar.xz
yuzu-5ed68e83db39e1f6790a625529f10f4e1d5a8f89.tar.zst
yuzu-5ed68e83db39e1f6790a625529f10f4e1d5a8f89.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_vulkan/vk_compute_pipeline.cpp15
-rw-r--r--src/video_core/renderer_vulkan/vk_compute_pipeline.h7
-rw-r--r--src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp14
-rw-r--r--src/video_core/renderer_vulkan/vk_graphics_pipeline.h7
4 files changed, 32 insertions, 11 deletions
diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp
index 6707842ab..0bb5b852d 100644
--- a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp
+++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp
@@ -55,8 +55,9 @@ ComputePipeline::ComputePipeline(const Device& device, VKDescriptorPool& descrip
.basePipelineHandle = 0,
.basePipelineIndex = 0,
});
- building_flag.test_and_set();
- building_flag.notify_all();
+ std::lock_guard lock{build_mutex};
+ is_built = true;
+ build_condvar.notify_one();
}};
if (thread_worker) {
thread_worker->QueueWork(std::move(func));
@@ -75,7 +76,8 @@ void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute,
size_t ssbo_index{};
for (const auto& desc : info.storage_buffers_descriptors) {
ASSERT(desc.count == 1);
- buffer_cache.BindComputeStorageBuffer(ssbo_index, desc.cbuf_index, desc.cbuf_offset, desc.is_written);
+ buffer_cache.BindComputeStorageBuffer(ssbo_index, desc.cbuf_index, desc.cbuf_offset,
+ desc.is_written);
++ssbo_index;
}
buffer_cache.UpdateComputeBuffers();
@@ -112,9 +114,12 @@ void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute,
PushImageDescriptors(info, samplers.data(), image_view_ids.data(), texture_cache,
update_descriptor_queue, image_index);
- if (!building_flag.test()) {
+ if (!is_built.load(std::memory_order::relaxed)) {
// Wait for the pipeline to be built
- scheduler.Record([this](vk::CommandBuffer) { building_flag.wait(false); });
+ scheduler.Record([this](vk::CommandBuffer) {
+ std::unique_lock lock{build_mutex};
+ build_condvar.wait(lock, [this] { return is_built.load(std::memory_order::relaxed); });
+ });
}
scheduler.Record([this](vk::CommandBuffer cmdbuf) {
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_COMPUTE, *pipeline);
diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.h b/src/video_core/renderer_vulkan/vk_compute_pipeline.h
index 02da504f7..104e6cc85 100644
--- a/src/video_core/renderer_vulkan/vk_compute_pipeline.h
+++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.h
@@ -4,6 +4,8 @@
#pragma once
+#include <mutex>
+#include <condition_variable>
#include <atomic>
#include "common/common_types.h"
@@ -47,7 +49,10 @@ private:
vk::PipelineLayout pipeline_layout;
vk::DescriptorUpdateTemplateKHR descriptor_update_template;
vk::Pipeline pipeline;
- std::atomic_flag building_flag{};
+
+ std::condition_variable build_condvar;
+ std::mutex build_mutex;
+ std::atomic_bool is_built{false};
};
} // namespace Vulkan
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
index e8c3a5624..67de3cb79 100644
--- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
+++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
@@ -135,8 +135,10 @@ GraphicsPipeline::GraphicsPipeline(Tegra::Engines::Maxwell3D& maxwell3d_,
const VkRenderPass render_pass{render_pass_cache.Get(MakeRenderPassKey(state))};
MakePipeline(device, render_pass);
- building_flag.test_and_set();
- building_flag.notify_all();
+
+ std::lock_guard lock{build_mutex};
+ is_built = true;
+ build_condvar.notify_one();
}};
if (worker_thread) {
worker_thread->QueueWork(std::move(func));
@@ -196,8 +198,12 @@ void GraphicsPipeline::Configure(bool is_indexed) {
texture_cache.UpdateRenderTargets(false);
scheduler.RequestRenderpass(texture_cache.GetFramebuffer());
- if (!building_flag.test()) {
- scheduler.Record([this](vk::CommandBuffer) { building_flag.wait(false); });
+ if (!is_built.load(std::memory_order::relaxed)) {
+ // Wait for the pipeline to be built
+ scheduler.Record([this](vk::CommandBuffer) {
+ std::unique_lock lock{build_mutex};
+ build_condvar.wait(lock, [this] { return is_built.load(std::memory_order::relaxed); });
+ });
}
if (scheduler.UpdateGraphicsPipeline(this)) {
scheduler.Record([this](vk::CommandBuffer cmdbuf) {
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h
index 4e0583157..7d14d2378 100644
--- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h
+++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h
@@ -6,6 +6,8 @@
#include <array>
#include <atomic>
+#include <condition_variable>
+#include <mutex>
#include "common/thread_worker.h"
#include "shader_recompiler/shader_info.h"
@@ -63,7 +65,10 @@ private:
vk::PipelineLayout pipeline_layout;
vk::DescriptorUpdateTemplateKHR descriptor_update_template;
vk::Pipeline pipeline;
- std::atomic_flag building_flag{};
+
+ std::condition_variable build_condvar;
+ std::mutex build_mutex;
+ std::atomic_bool is_built{false};
};
} // namespace Vulkan