diff options
Diffstat (limited to 'src/shader_recompiler/ir_opt/rescaling_pass.cpp')
| -rw-r--r-- | src/shader_recompiler/ir_opt/rescaling_pass.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/shader_recompiler/ir_opt/rescaling_pass.cpp b/src/shader_recompiler/ir_opt/rescaling_pass.cpp index d5b98ae6e..86c8f0c69 100644 --- a/src/shader_recompiler/ir_opt/rescaling_pass.cpp +++ b/src/shader_recompiler/ir_opt/rescaling_pass.cpp | |||
| @@ -84,10 +84,8 @@ void PatchImageQueryDimensions(IR::Block& block, IR::Inst& inst) { | |||
| 84 | } | 84 | } |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | void PatchImageFetch(IR::Block& block, IR::Inst& inst) { | 87 | void ScaleIntegerCoord(IR::IREmitter& ir, IR::Inst& inst, const IR::U1& is_scaled) { |
| 88 | IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)}; | ||
| 89 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | 88 | const auto info{inst.Flags<IR::TextureInstInfo>()}; |
| 90 | const IR::U1 is_scaled{ir.IsTextureScaled(ir.Imm32(info.descriptor_index))}; | ||
| 91 | const IR::Value coord{inst.Arg(1)}; | 89 | const IR::Value coord{inst.Arg(1)}; |
| 92 | switch (info.type) { | 90 | switch (info.type) { |
| 93 | case TextureType::Color1D: | 91 | case TextureType::Color1D: |
| @@ -121,6 +119,21 @@ void PatchImageFetch(IR::Block& block, IR::Inst& inst) { | |||
| 121 | } | 119 | } |
| 122 | } | 120 | } |
| 123 | 121 | ||
| 122 | void PatchImageFetch(IR::Block& block, IR::Inst& inst) { | ||
| 123 | IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)}; | ||
| 124 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 125 | const IR::U1 is_scaled{ir.IsTextureScaled(ir.Imm32(info.descriptor_index))}; | ||
| 126 | ScaleIntegerCoord(ir, inst, is_scaled); | ||
| 127 | } | ||
| 128 | |||
| 129 | void PatchImageRead(IR::Block& block, IR::Inst& inst) { | ||
| 130 | IR::IREmitter ir{block, IR::Block::InstructionList::s_iterator_to(inst)}; | ||
| 131 | const auto info{inst.Flags<IR::TextureInstInfo>()}; | ||
| 132 | // TODO: Scale conditionally | ||
| 133 | const IR::U1 is_scaled{IR::Value{true}}; | ||
| 134 | ScaleIntegerCoord(ir, inst, is_scaled); | ||
| 135 | } | ||
| 136 | |||
| 124 | void Visit(const IR::Program& program, IR::Block& block, IR::Inst& inst) { | 137 | void Visit(const IR::Program& program, IR::Block& block, IR::Inst& inst) { |
| 125 | const bool is_fragment_shader{program.stage == Stage::Fragment}; | 138 | const bool is_fragment_shader{program.stage == Stage::Fragment}; |
| 126 | switch (inst.GetOpcode()) { | 139 | switch (inst.GetOpcode()) { |
| @@ -144,6 +157,9 @@ void Visit(const IR::Program& program, IR::Block& block, IR::Inst& inst) { | |||
| 144 | case IR::Opcode::ImageFetch: | 157 | case IR::Opcode::ImageFetch: |
| 145 | PatchImageFetch(block, inst); | 158 | PatchImageFetch(block, inst); |
| 146 | break; | 159 | break; |
| 160 | case IR::Opcode::ImageRead: | ||
| 161 | PatchImageRead(block, inst); | ||
| 162 | break; | ||
| 147 | default: | 163 | default: |
| 148 | break; | 164 | break; |
| 149 | } | 165 | } |