diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2019-03-26 22:56:16 +0100 |
---|---|---|
committer | FernandoS27 <fsahmkow27@gmail.com> | 2019-04-08 17:23:45 +0200 |
commit | fe392fff2425c10c9683a4058c779d352b9855ec (patch) | |
tree | 3227202eb53093f9a22d9e704928ade70cda08c4 /src/video_core/shader/decode/texture.cpp | |
parent | Implement Bindless Samplers and TEX_B in the IR. (diff) | |
download | yuzu-fe392fff2425c10c9683a4058c779d352b9855ec.tar yuzu-fe392fff2425c10c9683a4058c779d352b9855ec.tar.gz yuzu-fe392fff2425c10c9683a4058c779d352b9855ec.tar.bz2 yuzu-fe392fff2425c10c9683a4058c779d352b9855ec.tar.lz yuzu-fe392fff2425c10c9683a4058c779d352b9855ec.tar.xz yuzu-fe392fff2425c10c9683a4058c779d352b9855ec.tar.zst yuzu-fe392fff2425c10c9683a4058c779d352b9855ec.zip |
Diffstat (limited to 'src/video_core/shader/decode/texture.cpp')
-rw-r--r-- | src/video_core/shader/decode/texture.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index 23f2ad999..3ac04f6b7 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp @@ -267,7 +267,7 @@ const Sampler& ShaderIR::GetSampler(const Tegra::Shader::Sampler& sampler, Textu // Otherwise create a new mapping for this sampler const std::size_t next_index = used_samplers.size(); - const Sampler entry{offset, next_index, type, is_array, is_shadow, false}; + const Sampler entry{offset, next_index, type, is_array, is_shadow}; return *used_samplers.emplace(entry).first; } @@ -281,20 +281,22 @@ const Sampler& ShaderIR::GetBindlessSampler(const Tegra::Shader::Register& reg, ASSERT(cbuf_offset_imm != nullptr); const auto cbuf_offset = cbuf_offset_imm->GetValue(); const auto cbuf_index = cbuf->GetIndex(); - const std::pair<u32, u32> cbuf_pair = {cbuf_index, cbuf_offset}; + const u64 cbuf_key = (cbuf_index << 32) | cbuf_offset; // If this sampler has already been used, return the existing mapping. - if (used_bindless_samplers.count(cbuf_pair) > 0) { - const auto& sampler = used_bindless_samplers[cbuf_pair]; - ASSERT(sampler.GetType() == type && sampler.IsArray() == is_array && - sampler.IsShadow() == is_shadow); - return sampler; + const auto itr = + std::find_if(used_samplers.begin(), used_samplers.end(), + [&](const Sampler& entry) { return entry.GetOffset() == cbuf_key; }); + if (itr != used_samplers.end()) { + ASSERT(itr->GetType() == type && itr->IsArray() == is_array && + itr->IsShadow() == is_shadow); + return *itr; } // Otherwise create a new mapping for this sampler - const std::size_t next_index = used_bindless_samplers.size(); - const Sampler entry{0, next_index, type, is_array, is_shadow, true}; - return (*used_bindless_samplers.emplace(std::make_pair(cbuf_pair, entry)).first).second; + const std::size_t next_index = used_samplers.size(); + const Sampler entry{cbuf_index, cbuf_offset, next_index, type, is_array, is_shadow}; + return *used_samplers.emplace(entry).first; } void ShaderIR::WriteTexInstructionFloat(NodeBlock& bb, Instruction instr, const Node4& components) { |