diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h index 80f44643e2..34941d6e8d 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h @@ -89,6 +89,10 @@ public: bool SupportsAlphaToOne() const noexcept { return fragment_has_color0_output; } + + bool UsesExtendedDynamicState() const noexcept { + return key.state.extended_dynamic_state != 0; + } GraphicsPipeline& operator=(GraphicsPipeline&&) noexcept = delete; GraphicsPipeline(GraphicsPipeline&&) noexcept = delete; diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cpp index cd5793746b..4e56055f97 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.cpp +++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp @@ -13,6 +13,7 @@ #include "common/thread.h" #include "video_core/renderer_vulkan/vk_command_pool.h" +#include "video_core/renderer_vulkan/vk_graphics_pipeline.h" #include "video_core/renderer_vulkan/vk_master_semaphore.h" #include "video_core/renderer_vulkan/vk_scheduler.h" #include "video_core/renderer_vulkan/vk_state_tracker.h" @@ -130,9 +131,27 @@ void Scheduler::RequestOutsideRenderPassOperationContext() { bool Scheduler::UpdateGraphicsPipeline(GraphicsPipeline* pipeline) { if (state.graphics_pipeline == pipeline) { + if (pipeline && pipeline->UsesExtendedDynamicState() && + state.needs_state_enable_refresh) { + state_tracker.InvalidateStateEnableFlag(); + state.needs_state_enable_refresh = false; + } return false; } + state.graphics_pipeline = pipeline; + + if (!pipeline) { + return true; + } + + if (!pipeline->UsesExtendedDynamicState()) { + state.needs_state_enable_refresh = true; + } else if (state.needs_state_enable_refresh) { + state_tracker.InvalidateStateEnableFlag(); + state.needs_state_enable_refresh = false; + } + return true; } diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h index 54ab8ba52b..edb8bd52d4 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.h +++ b/src/video_core/renderer_vulkan/vk_scheduler.h @@ -214,6 +214,7 @@ private: GraphicsPipeline* graphics_pipeline = nullptr; bool is_rescaling = false; bool rescaling_defined = false; + bool needs_state_enable_refresh = false; }; void WorkerThread(std::stop_token stop_token); diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.h b/src/video_core/renderer_vulkan/vk_state_tracker.h index 9af1efd2cf..74bae9e181 100644 --- a/src/video_core/renderer_vulkan/vk_state_tracker.h +++ b/src/video_core/renderer_vulkan/vk_state_tracker.h @@ -97,6 +97,10 @@ public: (*flags)[Dirty::Scissors] = true; } + void InvalidateStateEnableFlag() { + (*flags)[Dirty::StateEnable] = true; + } + bool TouchViewports() { const bool dirty_viewports = Exchange(Dirty::Viewports, false); const bool rescale_viewports = Exchange(VideoCommon::Dirty::RescaleViewports, false);