mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-05-07 13:37:46 +00:00
vk/pipe-compiler: Allow external definition of graphics properties during async compilation
This commit is contained in:
parent
d36a4bd858
commit
3d6773dd25
2 changed files with 72 additions and 7 deletions
|
|
@ -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<glsl::program> pipe_compiler::int_compile_graphics_pipe(
|
||||
graphics_pipe_create_callback_t pipe_info_create_fn,
|
||||
const std::vector<glsl::program_input>& vs_inputs,
|
||||
const std::vector<glsl::program_input>& 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<glsl::program> pipe_compiler::compile(
|
||||
const VkComputePipelineCreateInfo& create_info,
|
||||
op_flags flags, callback_t callback,
|
||||
|
|
@ -194,7 +210,7 @@ namespace vk
|
|||
const std::vector<glsl::program_input>& 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<glsl::program> pipe_compiler::compile(
|
||||
graphics_pipe_create_callback_t get_create_info,
|
||||
op_flags flags, callback_t callback,
|
||||
const std::vector<glsl::program_input>& vs_inputs,
|
||||
const std::vector<glsl::program_input>& 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)
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ namespace vk
|
|||
using op_flags = rsx::flags32_t;
|
||||
|
||||
using callback_t = std::function<void(std::unique_ptr<glsl::program>&)>;
|
||||
using graphics_pipe_create_callback_t = std::function<VkGraphicsPipelineCreateInfo()>;
|
||||
|
||||
pipe_compiler();
|
||||
~pipe_compiler();
|
||||
|
|
@ -89,6 +90,12 @@ namespace vk
|
|||
const std::vector<glsl::program_input>& vs_inputs = {},
|
||||
const std::vector<glsl::program_input>& fs_inputs = {});
|
||||
|
||||
std::unique_ptr<glsl::program> compile(
|
||||
graphics_pipe_create_callback_t get_create_info,
|
||||
op_flags flags, callback_t callback,
|
||||
const std::vector<glsl::program_input>& vs_inputs,
|
||||
const std::vector<glsl::program_input>& 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<glsl::program_input>& vs_in,
|
||||
const std::vector<glsl::program_input>& 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<glsl::program_input>& cs_in,
|
||||
|
|
@ -177,6 +205,12 @@ namespace vk
|
|||
const std::vector<glsl::program_input>& vs_inputs,
|
||||
const std::vector<glsl::program_input>& fs_inputs,
|
||||
op_flags flags);
|
||||
|
||||
std::unique_ptr<glsl::program> int_compile_graphics_pipe(
|
||||
graphics_pipe_create_callback_t pipe_info_create_fn,
|
||||
const std::vector<glsl::program_input>& vs_inputs,
|
||||
const std::vector<glsl::program_input>& fs_inputs,
|
||||
op_flags flags);
|
||||
};
|
||||
|
||||
void initialize_pipe_compiler(int num_worker_threads = -1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue