From 3b26f4f48a239c007bfa2b84ddf0e1a629625e89 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 18 Sep 2022 16:31:25 +0100 Subject: [PATCH] Expose way to check inter-pipeline descriptor compatibility Allows users to skip/use quick descriptor sync even after switching pipelines. --- .../interconnect/maxwell_3d/pipeline_manager.cpp | 15 +++++++++++++++ .../interconnect/maxwell_3d/pipeline_manager.h | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.cpp index 6350a914..e60c63ee 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.cpp @@ -561,6 +561,21 @@ namespace skyline::gpu::interconnect::maxwell3d { transitionCacheNextIdx = (transitionCacheNextIdx + 1) % transitionCache.size(); } + bool Pipeline::CheckBindingMatch(Pipeline *other) { + if (auto it{bindingMatchCache.find(other)}; it != bindingMatchCache.end()) + return it->second; + + for (size_t i{}; i < shaderStages.size(); i++) { + if (!shaderStages[i].BindingsEqual(other->shaderStages[i])) { + bindingMatchCache[other] = false; + return false; + } + } + + bindingMatchCache[other] = true; + return true; + } + static DynamicBufferBinding GetConstantBufferBinding(InterconnectContext &ctx, const Shader::Info &info, BufferView view, size_t idx) { ctx.executor.AttachBuffer(view); diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.h b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.h index 3782b7af..c82bb027 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.h @@ -26,6 +26,18 @@ namespace skyline::gpu::interconnect::maxwell3d { vk::ShaderStageFlagBits stage; vk::ShaderModule module; Shader::Info info; + + /** + * @return Whether the bindings for this stage match those of the input stage + */ + bool BindingsEqual(const ShaderStage &other) const { + return info.constant_buffer_descriptors == other.info.constant_buffer_descriptors && + info.storage_buffers_descriptors == other.info.storage_buffers_descriptors && + info.texture_buffer_descriptors == other.info.texture_buffer_descriptors && + info.image_buffer_descriptors == other.info.image_buffer_descriptors && + info.texture_descriptors == other.info.texture_descriptors && + info.image_descriptors == other.info.image_descriptors; + } }; struct DescriptorInfo { @@ -69,6 +81,8 @@ namespace skyline::gpu::interconnect::maxwell3d { std::array transitionCache{}; size_t transitionCacheNextIdx{}; + tsl::robin_map bindingMatchCache; //!< Cache of which pipelines have bindings that match this pipeline + public: PackedPipelineState sourcePackedState; @@ -78,6 +92,8 @@ namespace skyline::gpu::interconnect::maxwell3d { void AddTransition(Pipeline *next); + bool CheckBindingMatch(Pipeline *other); + void SyncDescriptors(InterconnectContext &ctx, ConstantBufferSet &constantBuffers); void SyncDescriptorsQuickBind(InterconnectContext &ctx, ConstantBufferSet &constantBuffers, ConstantBuffers::QuickBind quickBind);