diff --git a/rpcs3/Emu/RSX/VK/VKPipelineCompiler.cpp b/rpcs3/Emu/RSX/VK/VKPipelineCompiler.cpp index 99462e0602..286a30c3bf 100644 --- a/rpcs3/Emu/RSX/VK/VKPipelineCompiler.cpp +++ b/rpcs3/Emu/RSX/VK/VKPipelineCompiler.cpp @@ -34,16 +34,22 @@ namespace vk { for (auto&& job : m_work_queue.pop_all()) { - if (job.is_graphics_job) - { - auto compiled = int_compile_graphics_pipe(job.graphics_data, job.graphics_modules, job.inputs, {}, job.flags); - job.callback_func(compiled); - } - else + if (!job.is_graphics_job) { auto compiled = int_compile_compute_pipe(job.compute_data, job.inputs, job.flags); job.callback_func(compiled); + continue; } + + if (job.create_info_func) + { + auto compiled = int_compile_graphics_pipe(job.create_info_func, job.inputs, {}, job.flags); + job.callback_func(compiled); + continue; + } + + auto compiled = int_compile_graphics_pipe(job.graphics_data, job.graphics_modules, job.inputs, {}, job.flags); + job.callback_func(compiled); } thread_ctrl::wait_on(m_work_queue); @@ -173,6 +179,16 @@ namespace vk return int_compile_graphics_pipe(info, vs_inputs, fs_inputs, flags); } + std::unique_ptr pipe_compiler::int_compile_graphics_pipe( + graphics_pipe_create_callback_t pipe_info_create_fn, + const std::vector& vs_inputs, + const std::vector& fs_inputs, + op_flags flags) + { + VkGraphicsPipelineCreateInfo create_info = pipe_info_create_fn(); + return int_compile_graphics_pipe(create_info, vs_inputs, fs_inputs, flags); + } + std::unique_ptr pipe_compiler::compile( const VkComputePipelineCreateInfo& create_info, op_flags flags, callback_t callback, @@ -194,7 +210,7 @@ namespace vk const std::vector& fs_inputs) { // It is very inefficient to defer this as all pointers need to be saved - ensure(flags & COMPILE_INLINE); + ensure(flags & COMPILE_INLINE, "Asynchronous compilation is not allowed for raw graphics pipeline input"); return int_compile_graphics_pipe(create_info, vs_inputs, fs_inputs, flags); } @@ -216,6 +232,21 @@ namespace vk return {}; } + std::unique_ptr pipe_compiler::compile( + graphics_pipe_create_callback_t get_create_info, + op_flags flags, callback_t callback, + const std::vector& vs_inputs, + const std::vector& fs_inputs) + { + if (flags & COMPILE_INLINE) + { + return int_compile_graphics_pipe(get_create_info, vs_inputs, fs_inputs, flags); + } + + m_work_queue.push(get_create_info, vs_inputs, fs_inputs, flags, callback); + return {}; + } + void initialize_pipe_compiler(int num_worker_threads) { if (num_worker_threads == 0) diff --git a/rpcs3/Emu/RSX/VK/VKPipelineCompiler.h b/rpcs3/Emu/RSX/VK/VKPipelineCompiler.h index 762e8aadfc..e1cea3b04a 100644 --- a/rpcs3/Emu/RSX/VK/VKPipelineCompiler.h +++ b/rpcs3/Emu/RSX/VK/VKPipelineCompiler.h @@ -64,6 +64,7 @@ namespace vk using op_flags = rsx::flags32_t; using callback_t = std::function&)>; + using graphics_pipe_create_callback_t = std::function; pipe_compiler(); ~pipe_compiler(); @@ -89,6 +90,12 @@ namespace vk const std::vector& vs_inputs = {}, const std::vector& fs_inputs = {}); + std::unique_ptr compile( + graphics_pipe_create_callback_t get_create_info, + op_flags flags, callback_t callback, + const std::vector& vs_inputs, + const std::vector& fs_inputs); + void operator()(); private: @@ -111,6 +118,7 @@ namespace vk { bool is_graphics_job; callback_t callback_func; + graphics_pipe_create_callback_t create_info_func; vk::pipeline_props graphics_data; compute_pipeline_props compute_data; @@ -139,6 +147,26 @@ namespace vk inputs.insert(inputs.end(), fs_in.begin(), fs_in.end()); } + pipe_compiler_job( + graphics_pipe_create_callback_t pipe_info_create_fn, + const std::vector& vs_in, + const std::vector& fs_in, + op_flags flags_, + callback_t func) + { + callback_func = func; + create_info_func = pipe_info_create_fn; + is_graphics_job = true; + flags = flags_; + + graphics_modules[0] = VK_NULL_HANDLE; + graphics_modules[1] = VK_NULL_HANDLE; + + inputs.reserve(vs_in.size() + fs_in.size()); + inputs.insert(inputs.end(), vs_in.begin(), vs_in.end()); + inputs.insert(inputs.end(), fs_in.begin(), fs_in.end()); + } + pipe_compiler_job( const VkComputePipelineCreateInfo& props, const std::vector& cs_in, @@ -177,6 +205,12 @@ namespace vk const std::vector& vs_inputs, const std::vector& fs_inputs, op_flags flags); + + std::unique_ptr int_compile_graphics_pipe( + graphics_pipe_create_callback_t pipe_info_create_fn, + const std::vector& vs_inputs, + const std::vector& fs_inputs, + op_flags flags); }; void initialize_pipe_compiler(int num_worker_threads = -1);