summaryrefslogtreecommitdiff
path: root/src/video_core/shader/decode
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/shader/decode')
-rw-r--r--src/video_core/shader/decode/image.cpp40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/video_core/shader/decode/image.cpp b/src/video_core/shader/decode/image.cpp
index 77151a24b..008109a99 100644
--- a/src/video_core/shader/decode/image.cpp
+++ b/src/video_core/shader/decode/image.cpp
@@ -61,56 +61,54 @@ u32 ShaderIR::DecodeImage(NodeBlock& bb, u32 pc) {
61 } 61 }
62 62
63 const auto type{instr.sust.image_type}; 63 const auto type{instr.sust.image_type};
64 const auto& image{instr.sust.is_immediate ? GetImage(instr.image, type) 64 auto& image{instr.sust.is_immediate ? GetImage(instr.image, type)
65 : GetBindlessImage(instr.gpr39, type)}; 65 : GetBindlessImage(instr.gpr39, type)};
66 image.MarkWrite();
67
66 MetaImage meta{image, values}; 68 MetaImage meta{image, values};
67 const Node store{Operation(OperationCode::ImageStore, meta, std::move(coords))}; 69 const Node store{Operation(OperationCode::ImageStore, meta, std::move(coords))};
68 bb.push_back(store); 70 bb.push_back(store);
69 break; 71 break;
70 } 72 }
71 default: 73 default:
72 UNIMPLEMENTED_MSG("Unhandled conversion instruction: {}", opcode->get().GetName()); 74 UNIMPLEMENTED_MSG("Unhandled image instruction: {}", opcode->get().GetName());
73 } 75 }
74 76
75 return pc; 77 return pc;
76} 78}
77 79
78const Image& ShaderIR::GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type) { 80Image& ShaderIR::GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type) {
79 const auto offset{static_cast<std::size_t>(image.index.Value())}; 81 const auto offset{static_cast<u64>(image.index.Value())};
80 82
81 // If this image has already been used, return the existing mapping. 83 // If this image has already been used, return the existing mapping.
82 const auto itr{std::find_if(used_images.begin(), used_images.end(), 84 const auto it = used_images.find(offset);
83 [=](const Image& entry) { return entry.GetOffset() == offset; })}; 85 if (it != used_images.end()) {
84 if (itr != used_images.end()) { 86 ASSERT(it->second.GetType() == type);
85 ASSERT(itr->GetType() == type); 87 return it->second;
86 return *itr;
87 } 88 }
88 89
89 // Otherwise create a new mapping for this image. 90 // Otherwise create a new mapping for this image.
90 const std::size_t next_index{used_images.size()}; 91 const std::size_t next_index{used_images.size()};
91 const Image entry{offset, next_index, type}; 92 return used_images.emplace(offset, Image{offset, next_index, type}).first->second;
92 return *used_images.emplace(entry).first;
93} 93}
94 94
95const Image& ShaderIR::GetBindlessImage(Tegra::Shader::Register reg, 95Image& ShaderIR::GetBindlessImage(Tegra::Shader::Register reg, Tegra::Shader::ImageType type) {
96 Tegra::Shader::ImageType type) {
97 const Node image_register{GetRegister(reg)}; 96 const Node image_register{GetRegister(reg)};
98 const auto [base_image, cbuf_index, cbuf_offset]{ 97 const auto [base_image, cbuf_index, cbuf_offset]{
99 TrackCbuf(image_register, global_code, static_cast<s64>(global_code.size()))}; 98 TrackCbuf(image_register, global_code, static_cast<s64>(global_code.size()))};
100 const auto cbuf_key{(static_cast<u64>(cbuf_index) << 32) | static_cast<u64>(cbuf_offset)}; 99 const auto cbuf_key{(static_cast<u64>(cbuf_index) << 32) | static_cast<u64>(cbuf_offset)};
101 100
102 // If this image has already been used, return the existing mapping. 101 // If this image has already been used, return the existing mapping.
103 const auto itr{std::find_if(used_images.begin(), used_images.end(), 102 const auto it = used_images.find(cbuf_key);
104 [=](const Image& entry) { return entry.GetOffset() == cbuf_key; })}; 103 if (it != used_images.end()) {
105 if (itr != used_images.end()) { 104 ASSERT(it->second.GetType() == type);
106 ASSERT(itr->GetType() == type); 105 return it->second;
107 return *itr;
108 } 106 }
109 107
110 // Otherwise create a new mapping for this image. 108 // Otherwise create a new mapping for this image.
111 const std::size_t next_index{used_images.size()}; 109 const std::size_t next_index{used_images.size()};
112 const Image entry{cbuf_index, cbuf_offset, next_index, type}; 110 return used_images.emplace(cbuf_key, Image{cbuf_index, cbuf_offset, next_index, type})
113 return *used_images.emplace(entry).first; 111 .first->second;
114} 112}
115 113
116} // namespace VideoCommon::Shader 114} // namespace VideoCommon::Shader