diff options
| author | 2019-03-26 17:56:16 -0400 | |
|---|---|---|
| committer | 2019-04-08 11:23:45 -0400 | |
| commit | fe392fff2425c10c9683a4058c779d352b9855ec (patch) | |
| tree | 3227202eb53093f9a22d9e704928ade70cda08c4 /src/video_core/shader/decode | |
| parent | Implement Bindless Samplers and TEX_B in the IR. (diff) | |
| download | yuzu-fe392fff2425c10c9683a4058c779d352b9855ec.tar.gz yuzu-fe392fff2425c10c9683a4058c779d352b9855ec.tar.xz yuzu-fe392fff2425c10c9683a4058c779d352b9855ec.zip | |
Unify both sampler types.
Diffstat (limited to 'src/video_core/shader/decode')
| -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 | |||
| 267 | 267 | ||
| 268 | // Otherwise create a new mapping for this sampler | 268 | // Otherwise create a new mapping for this sampler |
| 269 | const std::size_t next_index = used_samplers.size(); | 269 | const std::size_t next_index = used_samplers.size(); |
| 270 | const Sampler entry{offset, next_index, type, is_array, is_shadow, false}; | 270 | const Sampler entry{offset, next_index, type, is_array, is_shadow}; |
| 271 | return *used_samplers.emplace(entry).first; | 271 | return *used_samplers.emplace(entry).first; |
| 272 | } | 272 | } |
| 273 | 273 | ||
| @@ -281,20 +281,22 @@ const Sampler& ShaderIR::GetBindlessSampler(const Tegra::Shader::Register& reg, | |||
| 281 | ASSERT(cbuf_offset_imm != nullptr); | 281 | ASSERT(cbuf_offset_imm != nullptr); |
| 282 | const auto cbuf_offset = cbuf_offset_imm->GetValue(); | 282 | const auto cbuf_offset = cbuf_offset_imm->GetValue(); |
| 283 | const auto cbuf_index = cbuf->GetIndex(); | 283 | const auto cbuf_index = cbuf->GetIndex(); |
| 284 | const std::pair<u32, u32> cbuf_pair = {cbuf_index, cbuf_offset}; | 284 | const u64 cbuf_key = (cbuf_index << 32) | cbuf_offset; |
| 285 | 285 | ||
| 286 | // If this sampler has already been used, return the existing mapping. | 286 | // If this sampler has already been used, return the existing mapping. |
| 287 | if (used_bindless_samplers.count(cbuf_pair) > 0) { | 287 | const auto itr = |
| 288 | const auto& sampler = used_bindless_samplers[cbuf_pair]; | 288 | std::find_if(used_samplers.begin(), used_samplers.end(), |
| 289 | ASSERT(sampler.GetType() == type && sampler.IsArray() == is_array && | 289 | [&](const Sampler& entry) { return entry.GetOffset() == cbuf_key; }); |
| 290 | sampler.IsShadow() == is_shadow); | 290 | if (itr != used_samplers.end()) { |
| 291 | return sampler; | 291 | ASSERT(itr->GetType() == type && itr->IsArray() == is_array && |
| 292 | itr->IsShadow() == is_shadow); | ||
| 293 | return *itr; | ||
| 292 | } | 294 | } |
| 293 | 295 | ||
| 294 | // Otherwise create a new mapping for this sampler | 296 | // Otherwise create a new mapping for this sampler |
| 295 | const std::size_t next_index = used_bindless_samplers.size(); | 297 | const std::size_t next_index = used_samplers.size(); |
| 296 | const Sampler entry{0, next_index, type, is_array, is_shadow, true}; | 298 | const Sampler entry{cbuf_index, cbuf_offset, next_index, type, is_array, is_shadow}; |
| 297 | return (*used_bindless_samplers.emplace(std::make_pair(cbuf_pair, entry)).first).second; | 299 | return *used_samplers.emplace(entry).first; |
| 298 | } | 300 | } |
| 299 | 301 | ||
| 300 | void ShaderIR::WriteTexInstructionFloat(NodeBlock& bb, Instruction instr, const Node4& components) { | 302 | void ShaderIR::WriteTexInstructionFloat(NodeBlock& bb, Instruction instr, const Node4& components) { |