summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/ir_opt/texture_pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/ir_opt/texture_pass.cpp')
-rw-r--r--src/shader_recompiler/ir_opt/texture_pass.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/shader_recompiler/ir_opt/texture_pass.cpp b/src/shader_recompiler/ir_opt/texture_pass.cpp
index a7b1fcfad..e1d5a2ce1 100644
--- a/src/shader_recompiler/ir_opt/texture_pass.cpp
+++ b/src/shader_recompiler/ir_opt/texture_pass.cpp
@@ -158,9 +158,11 @@ TextureInst MakeInst(Environment& env, IR::Block* block, IR::Inst& inst) {
158class Descriptors { 158class Descriptors {
159public: 159public:
160 explicit Descriptors(TextureBufferDescriptors& texture_buffer_descriptors_, 160 explicit Descriptors(TextureBufferDescriptors& texture_buffer_descriptors_,
161 ImageBufferDescriptors& image_buffer_descriptors_,
161 TextureDescriptors& texture_descriptors_, 162 TextureDescriptors& texture_descriptors_,
162 ImageDescriptors& image_descriptors_) 163 ImageDescriptors& image_descriptors_)
163 : texture_buffer_descriptors{texture_buffer_descriptors_}, 164 : texture_buffer_descriptors{texture_buffer_descriptors_},
165 image_buffer_descriptors{image_buffer_descriptors_},
164 texture_descriptors{texture_descriptors_}, image_descriptors{image_descriptors_} {} 166 texture_descriptors{texture_descriptors_}, image_descriptors{image_descriptors_} {}
165 167
166 u32 Add(const TextureBufferDescriptor& desc) { 168 u32 Add(const TextureBufferDescriptor& desc) {
@@ -170,6 +172,13 @@ public:
170 }); 172 });
171 } 173 }
172 174
175 u32 Add(const ImageBufferDescriptor& desc) {
176 return Add(image_buffer_descriptors, desc, [&desc](const auto& existing) {
177 return desc.format == existing.format && desc.cbuf_index == existing.cbuf_index &&
178 desc.cbuf_offset == existing.cbuf_offset;
179 });
180 }
181
173 u32 Add(const TextureDescriptor& desc) { 182 u32 Add(const TextureDescriptor& desc) {
174 return Add(texture_descriptors, desc, [&desc](const auto& existing) { 183 return Add(texture_descriptors, desc, [&desc](const auto& existing) {
175 return desc.cbuf_index == existing.cbuf_index && 184 return desc.cbuf_index == existing.cbuf_index &&
@@ -200,6 +209,7 @@ private:
200 } 209 }
201 210
202 TextureBufferDescriptors& texture_buffer_descriptors; 211 TextureBufferDescriptors& texture_buffer_descriptors;
212 ImageBufferDescriptors& image_buffer_descriptors;
203 TextureDescriptors& texture_descriptors; 213 TextureDescriptors& texture_descriptors;
204 ImageDescriptors& image_descriptors; 214 ImageDescriptors& image_descriptors;
205}; 215};
@@ -224,6 +234,7 @@ void TexturePass(Environment& env, IR::Program& program) {
224 }); 234 });
225 Descriptors descriptors{ 235 Descriptors descriptors{
226 program.info.texture_buffer_descriptors, 236 program.info.texture_buffer_descriptors,
237 program.info.image_buffer_descriptors,
227 program.info.texture_descriptors, 238 program.info.texture_descriptors,
228 program.info.image_descriptors, 239 program.info.image_descriptors,
229 }; 240 };
@@ -261,7 +272,13 @@ void TexturePass(Environment& env, IR::Program& program) {
261 case IR::Opcode::ImageWrite: { 272 case IR::Opcode::ImageWrite: {
262 const bool is_written{inst->GetOpcode() == IR::Opcode::ImageWrite}; 273 const bool is_written{inst->GetOpcode() == IR::Opcode::ImageWrite};
263 if (flags.type == TextureType::Buffer) { 274 if (flags.type == TextureType::Buffer) {
264 throw NotImplementedException("Image buffer"); 275 index = descriptors.Add(ImageBufferDescriptor{
276 .format = flags.image_format,
277 .is_written = is_written,
278 .cbuf_index = cbuf.index,
279 .cbuf_offset = cbuf.offset,
280 .count = 1,
281 });
265 } else { 282 } else {
266 index = descriptors.Add(ImageDescriptor{ 283 index = descriptors.Add(ImageDescriptor{
267 .type = flags.type, 284 .type = flags.type,