summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2020-11-21 01:21:08 -0800
committerGravatar GitHub2020-11-21 01:21:08 -0800
commit5502f3912574d147e4fc17eca3555301153eb65e (patch)
tree56a2eae73c9839994afe24fa11f24b50eade5ae6 /src
parentMerge pull request #4960 from liushuyu/master (diff)
parentasync_shaders: emplace threads into the worker thread vector (diff)
downloadyuzu-5502f3912574d147e4fc17eca3555301153eb65e.tar.gz
yuzu-5502f3912574d147e4fc17eca3555301153eb65e.tar.xz
yuzu-5502f3912574d147e4fc17eca3555301153eb65e.zip
Merge pull request #4955 from lioncash/move3
async_shaders: std::move data within QueueVulkanShader()
Diffstat (limited to 'src')
-rw-r--r--src/video_core/shader/async_shaders.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/video_core/shader/async_shaders.cpp b/src/video_core/shader/async_shaders.cpp
index 39cc3b869..6920afdf2 100644
--- a/src/video_core/shader/async_shaders.cpp
+++ b/src/video_core/shader/async_shaders.cpp
@@ -43,8 +43,8 @@ void AsyncShaders::AllocateWorkers() {
43 // Create workers 43 // Create workers
44 for (std::size_t i = 0; i < num_workers; i++) { 44 for (std::size_t i = 0; i < num_workers; i++) {
45 context_list.push_back(emu_window.CreateSharedContext()); 45 context_list.push_back(emu_window.CreateSharedContext());
46 worker_threads.push_back( 46 worker_threads.emplace_back(&AsyncShaders::ShaderCompilerThread, this,
47 std::thread(&AsyncShaders::ShaderCompilerThread, this, context_list[i].get())); 47 context_list[i].get());
48 } 48 }
49} 49}
50 50
@@ -106,8 +106,7 @@ std::vector<AsyncShaders::Result> AsyncShaders::GetCompletedWork() {
106 std::vector<Result> results; 106 std::vector<Result> results;
107 { 107 {
108 std::unique_lock lock{completed_mutex}; 108 std::unique_lock lock{completed_mutex};
109 results.assign(std::make_move_iterator(finished_work.begin()), 109 results = std::move(finished_work);
110 std::make_move_iterator(finished_work.end()));
111 finished_work.clear(); 110 finished_work.clear();
112 } 111 }
113 return results; 112 return results;
@@ -116,11 +115,10 @@ std::vector<AsyncShaders::Result> AsyncShaders::GetCompletedWork() {
116void AsyncShaders::QueueOpenGLShader(const OpenGL::Device& device, 115void AsyncShaders::QueueOpenGLShader(const OpenGL::Device& device,
117 Tegra::Engines::ShaderType shader_type, u64 uid, 116 Tegra::Engines::ShaderType shader_type, u64 uid,
118 std::vector<u64> code, std::vector<u64> code_b, 117 std::vector<u64> code, std::vector<u64> code_b,
119 u32 main_offset, 118 u32 main_offset, CompilerSettings compiler_settings,
120 VideoCommon::Shader::CompilerSettings compiler_settings, 119 const Registry& registry, VAddr cpu_addr) {
121 const VideoCommon::Shader::Registry& registry, 120 std::unique_lock lock(queue_mutex);
122 VAddr cpu_addr) { 121 pending_queue.push({
123 WorkerParams params{
124 .backend = device.UseAssemblyShaders() ? Backend::GLASM : Backend::OpenGL, 122 .backend = device.UseAssemblyShaders() ? Backend::GLASM : Backend::OpenGL,
125 .device = &device, 123 .device = &device,
126 .shader_type = shader_type, 124 .shader_type = shader_type,
@@ -131,9 +129,7 @@ void AsyncShaders::QueueOpenGLShader(const OpenGL::Device& device,
131 .compiler_settings = compiler_settings, 129 .compiler_settings = compiler_settings,
132 .registry = registry, 130 .registry = registry,
133 .cpu_address = cpu_addr, 131 .cpu_address = cpu_addr,
134 }; 132 });
135 std::unique_lock lock(queue_mutex);
136 pending_queue.push(std::move(params));
137 cv.notify_one(); 133 cv.notify_one();
138} 134}
139 135
@@ -145,7 +141,8 @@ void AsyncShaders::QueueVulkanShader(Vulkan::VKPipelineCache* pp_cache,
145 std::vector<VkDescriptorSetLayoutBinding> bindings, 141 std::vector<VkDescriptorSetLayoutBinding> bindings,
146 Vulkan::SPIRVProgram program, 142 Vulkan::SPIRVProgram program,
147 Vulkan::GraphicsPipelineCacheKey key) { 143 Vulkan::GraphicsPipelineCacheKey key) {
148 WorkerParams params{ 144 std::unique_lock lock(queue_mutex);
145 pending_queue.push({
149 .backend = Backend::Vulkan, 146 .backend = Backend::Vulkan,
150 .pp_cache = pp_cache, 147 .pp_cache = pp_cache,
151 .vk_device = &device, 148 .vk_device = &device,
@@ -153,13 +150,10 @@ void AsyncShaders::QueueVulkanShader(Vulkan::VKPipelineCache* pp_cache,
153 .descriptor_pool = &descriptor_pool, 150 .descriptor_pool = &descriptor_pool,
154 .update_descriptor_queue = &update_descriptor_queue, 151 .update_descriptor_queue = &update_descriptor_queue,
155 .renderpass_cache = &renderpass_cache, 152 .renderpass_cache = &renderpass_cache,
156 .bindings = bindings, 153 .bindings = std::move(bindings),
157 .program = program, 154 .program = std::move(program),
158 .key = key, 155 .key = key,
159 }; 156 });
160
161 std::unique_lock lock(queue_mutex);
162 pending_queue.push(std::move(params));
163 cv.notify_one(); 157 cv.notify_one();
164} 158}
165 159