[Vulkan] Add thread pool for async shader compilation

Uses priority queue with higher priority on shaders with visible
render targets
This commit is contained in:
Herman S.
2025-09-23 21:06:51 +09:00
parent 19c5401eda
commit ccf8fb66f5
3 changed files with 324 additions and 60 deletions

View File

@@ -2446,17 +2446,27 @@ bool VulkanCommandProcessor::IssueDraw(xenos::PrimitiveType prim_type,
// Create the pipeline (for this, need the render pass from the render target
// cache), translating the shaders - doing this now to obtain the used
// textures.
VkPipeline pipeline;
const VulkanPipelineCache::PipelineLayoutProvider* pipeline_layout_provider;
VulkanPipelineCache::Pipeline* pipeline;
if (!pipeline_cache_->ConfigurePipeline(
vertex_shader_translation, pixel_shader_translation,
primitive_processing_result, normalized_depth_control,
normalized_color_mask,
render_target_cache_->last_update_render_pass_key(), pipeline,
pipeline_layout_provider)) {
render_target_cache_->last_update_render_pass_key(), &pipeline)) {
return false;
}
VkPipeline current_pipeline =
pipeline->pipeline.load(std::memory_order_acquire);
if (current_pipeline == VK_NULL_HANDLE) {
// Pipeline is not ready yet - wait for it to be created.
pipeline_cache_->EndSubmission();
current_pipeline = pipeline->pipeline.load(std::memory_order_acquire);
if (current_pipeline == VK_NULL_HANDLE) {
// Still not ready - something is wrong.
return false;
}
}
// Update the textures before most other work in the submission because
// samplers depend on this (and in case of sampler overflow in a submission,
// submissions must be split) - may perform dispatches and copying.
@@ -2470,14 +2480,17 @@ bool VulkanCommandProcessor::IssueDraw(xenos::PrimitiveType prim_type,
// Update the graphics pipeline, and if the new graphics pipeline has a
// different layout, invalidate incompatible descriptor sets before updating
// current_guest_graphics_pipeline_layout_.
if (current_guest_graphics_pipeline_ != pipeline) {
// The pipeline may be not ready yet if created asynchronously.
// EndSubmission must be called before submitting the command buffer to
// await its creation.
if (current_guest_graphics_pipeline_ != current_pipeline) {
deferred_command_buffer_.CmdVkBindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS,
pipeline);
current_guest_graphics_pipeline_ = pipeline;
current_pipeline);
current_guest_graphics_pipeline_ = current_pipeline;
current_external_graphics_pipeline_ = VK_NULL_HANDLE;
}
auto pipeline_layout =
static_cast<const PipelineLayout*>(pipeline_layout_provider);
static_cast<const PipelineLayout*>(pipeline->pipeline_layout);
if (current_guest_graphics_pipeline_layout_ != pipeline_layout) {
if (current_guest_graphics_pipeline_layout_) {
// Keep descriptor set layouts for which the new pipeline layout is