diff options
Diffstat (limited to 'src/shader_recompiler/ir_opt/texture_pass.cpp')
| -rw-r--r-- | src/shader_recompiler/ir_opt/texture_pass.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/shader_recompiler/ir_opt/texture_pass.cpp b/src/shader_recompiler/ir_opt/texture_pass.cpp index 0167dd06e..dfacf848f 100644 --- a/src/shader_recompiler/ir_opt/texture_pass.cpp +++ b/src/shader_recompiler/ir_opt/texture_pass.cpp | |||
| @@ -54,6 +54,9 @@ IR::Opcode IndexedInstruction(const IR::Inst& inst) { | |||
| 54 | case IR::Opcode::BindlessImageFetch: | 54 | case IR::Opcode::BindlessImageFetch: |
| 55 | case IR::Opcode::BoundImageFetch: | 55 | case IR::Opcode::BoundImageFetch: |
| 56 | return IR::Opcode::ImageFetch; | 56 | return IR::Opcode::ImageFetch; |
| 57 | case IR::Opcode::BoundImageQueryDimensions: | ||
| 58 | case IR::Opcode::BindlessImageQueryDimensions: | ||
| 59 | return IR::Opcode::ImageQueryDimensions; | ||
| 57 | default: | 60 | default: |
| 58 | return IR::Opcode::Void; | 61 | return IR::Opcode::Void; |
| 59 | } | 62 | } |
| @@ -68,6 +71,7 @@ bool IsBindless(const IR::Inst& inst) { | |||
| 68 | case IR::Opcode::BindlessImageGather: | 71 | case IR::Opcode::BindlessImageGather: |
| 69 | case IR::Opcode::BindlessImageGatherDref: | 72 | case IR::Opcode::BindlessImageGatherDref: |
| 70 | case IR::Opcode::BindlessImageFetch: | 73 | case IR::Opcode::BindlessImageFetch: |
| 74 | case IR::Opcode::BindlessImageQueryDimensions: | ||
| 71 | return true; | 75 | return true; |
| 72 | case IR::Opcode::BoundImageSampleImplicitLod: | 76 | case IR::Opcode::BoundImageSampleImplicitLod: |
| 73 | case IR::Opcode::BoundImageSampleExplicitLod: | 77 | case IR::Opcode::BoundImageSampleExplicitLod: |
| @@ -76,6 +80,7 @@ bool IsBindless(const IR::Inst& inst) { | |||
| 76 | case IR::Opcode::BoundImageGather: | 80 | case IR::Opcode::BoundImageGather: |
| 77 | case IR::Opcode::BoundImageGatherDref: | 81 | case IR::Opcode::BoundImageGatherDref: |
| 78 | case IR::Opcode::BoundImageFetch: | 82 | case IR::Opcode::BoundImageFetch: |
| 83 | case IR::Opcode::BoundImageQueryDimensions: | ||
| 79 | return false; | 84 | return false; |
| 80 | default: | 85 | default: |
| 81 | throw InvalidArgument("Invalid opcode {}", inst.Opcode()); | 86 | throw InvalidArgument("Invalid opcode {}", inst.Opcode()); |
| @@ -198,13 +203,20 @@ void TexturePass(Environment& env, IR::Program& program) { | |||
| 198 | for (TextureInst& texture_inst : to_replace) { | 203 | for (TextureInst& texture_inst : to_replace) { |
| 199 | // TODO: Handle arrays | 204 | // TODO: Handle arrays |
| 200 | IR::Inst* const inst{texture_inst.inst}; | 205 | IR::Inst* const inst{texture_inst.inst}; |
| 206 | inst->ReplaceOpcode(IndexedInstruction(*inst)); | ||
| 207 | |||
| 208 | const auto& cbuf{texture_inst.cbuf}; | ||
| 209 | auto flags{inst->Flags<IR::TextureInstInfo>()}; | ||
| 210 | if (inst->Opcode() == IR::Opcode::ImageQueryDimensions) { | ||
| 211 | flags.type.Assign(env.ReadTextureType(cbuf.index, cbuf.offset)); | ||
| 212 | inst->SetFlags(flags); | ||
| 213 | } | ||
| 201 | const u32 index{descriptors.Add(TextureDescriptor{ | 214 | const u32 index{descriptors.Add(TextureDescriptor{ |
| 202 | .type{inst->Flags<IR::TextureInstInfo>().type}, | 215 | .type{flags.type}, |
| 203 | .cbuf_index{texture_inst.cbuf.index}, | 216 | .cbuf_index{cbuf.index}, |
| 204 | .cbuf_offset{texture_inst.cbuf.offset}, | 217 | .cbuf_offset{cbuf.offset}, |
| 205 | .count{1}, | 218 | .count{1}, |
| 206 | })}; | 219 | })}; |
| 207 | inst->ReplaceOpcode(IndexedInstruction(*inst)); | ||
| 208 | inst->SetArg(0, IR::Value{index}); | 220 | inst->SetArg(0, IR::Value{index}); |
| 209 | } | 221 | } |
| 210 | } | 222 | } |