diff options
author | FernandoS27 <fsahmkow27@gmail.com> | 2021-04-19 01:03:38 +0200 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:29 +0200 |
commit | b541f5e5e333a8ec8c3569e02d67e59ad14217c2 (patch) | |
tree | 5b19bdd92d74ce8e32be75cfa2c27a4612a663de /src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp | |
parent | shader: Implement delegation of Exit to dispatcher on CFG (diff) | |
download | yuzu-b541f5e5e333a8ec8c3569e02d67e59ad14217c2.tar yuzu-b541f5e5e333a8ec8c3569e02d67e59ad14217c2.tar.gz yuzu-b541f5e5e333a8ec8c3569e02d67e59ad14217c2.tar.bz2 yuzu-b541f5e5e333a8ec8c3569e02d67e59ad14217c2.tar.lz yuzu-b541f5e5e333a8ec8c3569e02d67e59ad14217c2.tar.xz yuzu-b541f5e5e333a8ec8c3569e02d67e59ad14217c2.tar.zst yuzu-b541f5e5e333a8ec8c3569e02d67e59ad14217c2.zip |
Diffstat (limited to 'src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp')
-rw-r--r-- | src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp index 87eca2a0d..1d11a00d8 100644 --- a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp +++ b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp @@ -499,4 +499,30 @@ void GlobalMemoryToStorageBufferPass(IR::Program& program) { } } +template <typename Descriptors, typename Descriptor, typename Func> +static u32 Add(Descriptors& descriptors, const Descriptor& desc, Func&& pred) { + // TODO: Handle arrays + const auto it{std::ranges::find_if(descriptors, pred)}; + if (it != descriptors.end()) { + return static_cast<u32>(std::distance(descriptors.begin(), it)); + } + descriptors.push_back(desc); + return static_cast<u32>(descriptors.size()) - 1; +} + +void JoinStorageInfo(Info& base, Info& source) { + auto& descriptors = base.storage_buffers_descriptors; + for (auto& desc : source.storage_buffers_descriptors) { + auto it{std::ranges::find_if(descriptors, [&desc](const auto& existing) { + return desc.cbuf_index == existing.cbuf_index && + desc.cbuf_offset == existing.cbuf_offset && desc.count == existing.count; + })}; + if (it != descriptors.end()) { + it->is_written |= desc.is_written; + continue; + } + descriptors.push_back(desc); + } +} + } // namespace Shader::Optimization |