diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/shader_recompiler/ir_opt/rescaling_pass.cpp | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/src/shader_recompiler/ir_opt/rescaling_pass.cpp b/src/shader_recompiler/ir_opt/rescaling_pass.cpp index 4d23b60c8..8bbaa55e4 100644 --- a/src/shader_recompiler/ir_opt/rescaling_pass.cpp +++ b/src/shader_recompiler/ir_opt/rescaling_pass.cpp | |||
| @@ -14,45 +14,39 @@ | |||
| 14 | 14 | ||
| 15 | namespace Shader::Optimization { | 15 | namespace Shader::Optimization { |
| 16 | namespace { | 16 | namespace { |
| 17 | void VisitMark(const IR::Program& program, IR::Inst& inst) { | 17 | void VisitMark(const IR::Program& program, const IR::Inst& inst) { |
| 18 | const bool is_fragment_shader{program.stage == Stage::Fragment}; | 18 | const bool is_fragment_shader{program.stage == Stage::Fragment}; |
| 19 | if (!is_fragment_shader) { | ||
| 20 | return; | ||
| 21 | } | ||
| 19 | switch (inst.GetOpcode()) { | 22 | switch (inst.GetOpcode()) { |
| 20 | case IR::Opcode::ShuffleIndex: | 23 | case IR::Opcode::ShuffleIndex: |
| 21 | case IR::Opcode::ShuffleUp: | 24 | case IR::Opcode::ShuffleUp: |
| 22 | case IR::Opcode::ShuffleDown: | 25 | case IR::Opcode::ShuffleDown: |
| 23 | case IR::Opcode::ShuffleButterfly: { | 26 | case IR::Opcode::ShuffleButterfly: { |
| 24 | const auto try_mark = [is_fragment_shader](IR::Inst* op) { | 27 | const IR::Value shfl_arg{inst.Arg(0)}; |
| 25 | const IR::Attribute attr{op->Arg(0).Attribute()}; | 28 | if (shfl_arg.IsImmediate()) { |
| 29 | break; | ||
| 30 | } | ||
| 31 | const IR::Inst* const arg_inst{shfl_arg.InstRecursive()}; | ||
| 32 | if (arg_inst->GetOpcode() != IR::Opcode::BitCastU32F32) { | ||
| 33 | break; | ||
| 34 | } | ||
| 35 | const IR::Value bitcast_arg{arg_inst->Arg(0)}; | ||
| 36 | if (bitcast_arg.IsImmediate()) { | ||
| 37 | break; | ||
| 38 | } | ||
| 39 | IR::Inst* const bitcast_inst{bitcast_arg.InstRecursive()}; | ||
| 40 | if (bitcast_inst->GetOpcode() == IR::Opcode::GetAttribute) { | ||
| 41 | const IR::Attribute attr{bitcast_inst->Arg(0).Attribute()}; | ||
| 26 | switch (attr) { | 42 | switch (attr) { |
| 27 | case IR::Attribute::PositionX: | 43 | case IR::Attribute::PositionX: |
| 28 | case IR::Attribute::PositionY: | 44 | case IR::Attribute::PositionY: |
| 29 | if (is_fragment_shader) { | 45 | bitcast_inst->SetFlags<u32>(0xDEADBEEF); |
| 30 | op->SetFlags<u32>(0xDEADBEEF); | ||
| 31 | } | ||
| 32 | break; | 46 | break; |
| 33 | default: | 47 | default: |
| 34 | break; | 48 | break; |
| 35 | } | 49 | } |
| 36 | }; | ||
| 37 | const IR::Value param_1{inst.Arg(0)}; | ||
| 38 | if (param_1.IsImmediate()) { | ||
| 39 | break; | ||
| 40 | } | ||
| 41 | IR::Inst* op_a{param_1.InstRecursive()}; | ||
| 42 | if (op_a->GetOpcode() == IR::Opcode::GetAttribute) { | ||
| 43 | try_mark(op_a); | ||
| 44 | break; | ||
| 45 | } | ||
| 46 | if (op_a->GetOpcode() != IR::Opcode::BitCastF32U32) { | ||
| 47 | break; | ||
| 48 | } | ||
| 49 | const IR::Value param_2{op_a->Arg(0)}; | ||
| 50 | if (param_2.IsImmediate()) { | ||
| 51 | break; | ||
| 52 | } | ||
| 53 | IR::Inst* op_b{param_2.InstRecursive()}; | ||
| 54 | if (op_b->GetOpcode() == IR::Opcode::GetAttribute) { | ||
| 55 | try_mark(op_b); | ||
| 56 | } | 50 | } |
| 57 | break; | 51 | break; |
| 58 | } | 52 | } |