diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2019-09-23 20:02:02 +0200 |
---|---|---|
committer | FernandoS27 <fsahmkow27@gmail.com> | 2019-10-25 15:01:29 +0200 |
commit | 1a58f45d76fe7756dd365e099d1536da769c1eab (patch) | |
tree | 668a61e870c57249edf94ba2e2002d3ace18b118 /src/video_core/shader/const_buffer_locker.h | |
parent | Shader_IR: Implement BRX tracking. (diff) | |
download | yuzu-1a58f45d76fe7756dd365e099d1536da769c1eab.tar yuzu-1a58f45d76fe7756dd365e099d1536da769c1eab.tar.gz yuzu-1a58f45d76fe7756dd365e099d1536da769c1eab.tar.bz2 yuzu-1a58f45d76fe7756dd365e099d1536da769c1eab.tar.lz yuzu-1a58f45d76fe7756dd365e099d1536da769c1eab.tar.xz yuzu-1a58f45d76fe7756dd365e099d1536da769c1eab.tar.zst yuzu-1a58f45d76fe7756dd365e099d1536da769c1eab.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/shader/const_buffer_locker.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/video_core/shader/const_buffer_locker.h b/src/video_core/shader/const_buffer_locker.h new file mode 100644 index 000000000..39e62584d --- /dev/null +++ b/src/video_core/shader/const_buffer_locker.h @@ -0,0 +1,50 @@ +// Copyright 2019 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <unordered_map> +#include "common/common_types.h" +#include "common/hash.h" +#include "video_core/engines/const_buffer_engine_interface.h" + +namespace VideoCommon::Shader { + +class ConstBufferLocker { +public: + explicit ConstBufferLocker(Tegra::Engines::ShaderType shader_stage); + + explicit ConstBufferLocker(Tegra::Engines::ShaderType shader_stage, + Tegra::Engines::ConstBufferEngineInterface* engine); + + // Checks if an engine is setup, it may be possible that during disk shader + // cache run, the engines have not been created yet. + bool IsEngineSet() const; + + // Use this to set/change the engine used for this shader. + void SetEngine(Tegra::Engines::ConstBufferEngineInterface* engine); + + // Retrieves a key from the locker, if it's registered, it will give the + // registered value, if not it will obtain it from maxwell3d and register it. + std::optional<u32> ObtainKey(u32 buffer, u32 offset); + + // Manually inserts a key. + void InsertKey(u32 buffer, u32 offset, u32 value); + + // Retrieves the number of keys registered. + u32 NumKeys() const; + + // Gives an accessor to the key's database. + const std::unordered_map<std::pair<u32, u32>, u32, Common::PairHash>& AccessKeys() const; + + // Checks keys against maxwell3d's current const buffers. Returns true if they + // are the same value, false otherwise; + bool AreKeysConsistant() const; + +private: + Tegra::Engines::ConstBufferEngineInterface* engine; + Tegra::Engines::ShaderType shader_stage; + std::unordered_map<std::pair<u32, u32>, u32, Common::PairHash> keys{}; +}; +} // namespace VideoCommon::Shader |