From 78f3e8a75792c976eb5bfa6df4c020d898642684 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Thu, 26 Sep 2019 00:23:08 -0300 Subject: gl_shader_cache: Implement locker variants invalidation --- src/video_core/shader/const_buffer_locker.cpp | 28 +++++++++++++++------------ src/video_core/shader/const_buffer_locker.h | 3 +++ 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'src/video_core/shader') diff --git a/src/video_core/shader/const_buffer_locker.cpp b/src/video_core/shader/const_buffer_locker.cpp index fda9e3c38..592bbf657 100644 --- a/src/video_core/shader/const_buffer_locker.cpp +++ b/src/video_core/shader/const_buffer_locker.cpp @@ -82,23 +82,27 @@ bool ConstBufferLocker::IsConsistent() const { return false; } return std::all_of(keys.begin(), keys.end(), - [](const auto& key) { - const auto [value, other_value] = key.first; - return value == other_value; + [this](const auto& pair) { + const auto [cbuf, offset] = pair.first; + const auto value = pair.second; + return value == engine->AccessConstBuffer32(stage, cbuf, offset); }) && std::all_of(bound_samplers.begin(), bound_samplers.end(), [this](const auto& sampler) { const auto [key, value] = sampler; - const auto other_value = engine->AccessBoundSampler(stage, key); - return value == other_value; + return value == engine->AccessBoundSampler(stage, key); }) && - std::all_of( - bindless_samplers.begin(), bindless_samplers.end(), [this](const auto& sampler) { - const auto [cbuf, offset] = sampler.first; - const auto value = sampler.second; - const auto other_value = engine->AccessBindlessSampler(stage, cbuf, offset); - return value == other_value; - }); + std::all_of(bindless_samplers.begin(), bindless_samplers.end(), + [this](const auto& sampler) { + const auto [cbuf, offset] = sampler.first; + const auto value = sampler.second; + return value == engine->AccessBindlessSampler(stage, cbuf, offset); + }); +} + +bool ConstBufferLocker::HasEqualKeys(const ConstBufferLocker& rhs) const { + return keys == rhs.keys && bound_samplers == rhs.bound_samplers && + bindless_samplers == rhs.bindless_samplers; } } // namespace VideoCommon::Shader diff --git a/src/video_core/shader/const_buffer_locker.h b/src/video_core/shader/const_buffer_locker.h index 417d5a16f..966537fd6 100644 --- a/src/video_core/shader/const_buffer_locker.h +++ b/src/video_core/shader/const_buffer_locker.h @@ -44,6 +44,9 @@ public: /// the same value, false otherwise; bool IsConsistent() const; + /// Returns true if the keys are equal to the other ones in the locker. + bool HasEqualKeys(const ConstBufferLocker& rhs) const; + /// Gives an getter to the const buffer keys in the database. const KeyMap& GetKeys() const { return keys; -- cgit v1.2.3