Merge pull request #4955 from lioncash/move3

async_shaders: std::move data within QueueVulkanShader()
master
bunnei 2020-11-21 01:21:08 +07:00 committed by GitHub
commit 5502f39125
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 19 deletions

@ -43,8 +43,8 @@ void AsyncShaders::AllocateWorkers() {
// Create workers // Create workers
for (std::size_t i = 0; i < num_workers; i++) { for (std::size_t i = 0; i < num_workers; i++) {
context_list.push_back(emu_window.CreateSharedContext()); context_list.push_back(emu_window.CreateSharedContext());
worker_threads.push_back( worker_threads.emplace_back(&AsyncShaders::ShaderCompilerThread, this,
std::thread(&AsyncShaders::ShaderCompilerThread, this, context_list[i].get())); context_list[i].get());
} }
} }
@ -106,8 +106,7 @@ std::vector<AsyncShaders::Result> AsyncShaders::GetCompletedWork() {
std::vector<Result> results; std::vector<Result> results;
{ {
std::unique_lock lock{completed_mutex}; std::unique_lock lock{completed_mutex};
results.assign(std::make_move_iterator(finished_work.begin()), results = std::move(finished_work);
std::make_move_iterator(finished_work.end()));
finished_work.clear(); finished_work.clear();
} }
return results; return results;
@ -116,11 +115,10 @@ std::vector<AsyncShaders::Result> AsyncShaders::GetCompletedWork() {
void AsyncShaders::QueueOpenGLShader(const OpenGL::Device& device, void AsyncShaders::QueueOpenGLShader(const OpenGL::Device& device,
Tegra::Engines::ShaderType shader_type, u64 uid, Tegra::Engines::ShaderType shader_type, u64 uid,
std::vector<u64> code, std::vector<u64> code_b, std::vector<u64> code, std::vector<u64> code_b,
u32 main_offset, u32 main_offset, CompilerSettings compiler_settings,
VideoCommon::Shader::CompilerSettings compiler_settings, const Registry& registry, VAddr cpu_addr) {
const VideoCommon::Shader::Registry& registry, std::unique_lock lock(queue_mutex);
VAddr cpu_addr) { pending_queue.push({
WorkerParams params{
.backend = device.UseAssemblyShaders() ? Backend::GLASM : Backend::OpenGL, .backend = device.UseAssemblyShaders() ? Backend::GLASM : Backend::OpenGL,
.device = &device, .device = &device,
.shader_type = shader_type, .shader_type = shader_type,
@ -131,9 +129,7 @@ void AsyncShaders::QueueOpenGLShader(const OpenGL::Device& device,
.compiler_settings = compiler_settings, .compiler_settings = compiler_settings,
.registry = registry, .registry = registry,
.cpu_address = cpu_addr, .cpu_address = cpu_addr,
}; });
std::unique_lock lock(queue_mutex);
pending_queue.push(std::move(params));
cv.notify_one(); cv.notify_one();
} }
@ -145,7 +141,8 @@ void AsyncShaders::QueueVulkanShader(Vulkan::VKPipelineCache* pp_cache,
std::vector<VkDescriptorSetLayoutBinding> bindings, std::vector<VkDescriptorSetLayoutBinding> bindings,
Vulkan::SPIRVProgram program, Vulkan::SPIRVProgram program,
Vulkan::GraphicsPipelineCacheKey key) { Vulkan::GraphicsPipelineCacheKey key) {
WorkerParams params{ std::unique_lock lock(queue_mutex);
pending_queue.push({
.backend = Backend::Vulkan, .backend = Backend::Vulkan,
.pp_cache = pp_cache, .pp_cache = pp_cache,
.vk_device = &device, .vk_device = &device,
@ -153,13 +150,10 @@ void AsyncShaders::QueueVulkanShader(Vulkan::VKPipelineCache* pp_cache,
.descriptor_pool = &descriptor_pool, .descriptor_pool = &descriptor_pool,
.update_descriptor_queue = &update_descriptor_queue, .update_descriptor_queue = &update_descriptor_queue,
.renderpass_cache = &renderpass_cache, .renderpass_cache = &renderpass_cache,
.bindings = bindings, .bindings = std::move(bindings),
.program = program, .program = std::move(program),
.key = key, .key = key,
}; });
std::unique_lock lock(queue_mutex);
pending_queue.push(std::move(params));
cv.notify_one(); cv.notify_one();
} }