diff options
| author | 2021-03-26 16:46:07 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:24 -0400 | |
| commit | d9c5bd9509e82fcde72c18663989931f97ed6518 (patch) | |
| tree | d6575e66d66a8abc8ee8776c1c2536c052424787 /src/shader_recompiler/ir_opt/constant_propagation_pass.cpp | |
| parent | shader: Add IR opcode for ImageFetch (diff) | |
| download | yuzu-d9c5bd9509e82fcde72c18663989931f97ed6518.tar.gz yuzu-d9c5bd9509e82fcde72c18663989931f97ed6518.tar.xz yuzu-d9c5bd9509e82fcde72c18663989931f97ed6518.zip | |
shader: Refactor PTP and other minor changes
Diffstat (limited to 'src/shader_recompiler/ir_opt/constant_propagation_pass.cpp')
| -rw-r--r-- | src/shader_recompiler/ir_opt/constant_propagation_pass.cpp | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp b/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp index 12159e738..052f1609b 100644 --- a/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp +++ b/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp | |||
| @@ -355,17 +355,6 @@ void FoldBranchConditional(IR::Inst& inst) { | |||
| 355 | } | 355 | } |
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | void FoldConstantComposite(IR::Inst& inst, size_t amount = 2) { | ||
| 359 | for (size_t i = 0; i < amount; i++) { | ||
| 360 | if (!inst.Arg(i).IsConstantContainer()) { | ||
| 361 | return; | ||
| 362 | } | ||
| 363 | } | ||
| 364 | auto info{inst.Flags<IR::CompositeDecoration>()}; | ||
| 365 | info.is_constant = true; | ||
| 366 | inst.SetFlags(info); | ||
| 367 | } | ||
| 368 | |||
| 369 | void ConstantPropagation(IR::Block& block, IR::Inst& inst) { | 358 | void ConstantPropagation(IR::Block& block, IR::Inst& inst) { |
| 370 | switch (inst.Opcode()) { | 359 | switch (inst.Opcode()) { |
| 371 | case IR::Opcode::GetRegister: | 360 | case IR::Opcode::GetRegister: |
| @@ -391,13 +380,6 @@ void ConstantPropagation(IR::Block& block, IR::Inst& inst) { | |||
| 391 | case IR::Opcode::SelectF32: | 380 | case IR::Opcode::SelectF32: |
| 392 | case IR::Opcode::SelectF64: | 381 | case IR::Opcode::SelectF64: |
| 393 | return FoldSelect(inst); | 382 | return FoldSelect(inst); |
| 394 | case IR::Opcode::CompositeConstructU32x2: | ||
| 395 | case IR::Opcode::CompositeConstructF16x2: | ||
| 396 | case IR::Opcode::CompositeConstructF32x2: | ||
| 397 | case IR::Opcode::CompositeConstructF64x2: | ||
| 398 | return FoldConstantComposite(inst, 2); | ||
| 399 | case IR::Opcode::CompositeConstructArrayU32x2: | ||
| 400 | return FoldConstantComposite(inst, 4); | ||
| 401 | case IR::Opcode::FPMul32: | 383 | case IR::Opcode::FPMul32: |
| 402 | return FoldFPMul32(inst); | 384 | return FoldFPMul32(inst); |
| 403 | case IR::Opcode::LogicalAnd: | 385 | case IR::Opcode::LogicalAnd: |
| @@ -423,12 +405,12 @@ void ConstantPropagation(IR::Block& block, IR::Inst& inst) { | |||
| 423 | return; | 405 | return; |
| 424 | case IR::Opcode::BitFieldSExtract: | 406 | case IR::Opcode::BitFieldSExtract: |
| 425 | FoldWhenAllImmediates(inst, [](s32 base, u32 shift, u32 count) { | 407 | FoldWhenAllImmediates(inst, [](s32 base, u32 shift, u32 count) { |
| 426 | const size_t back_shift = static_cast<size_t>(shift) + static_cast<size_t>(count); | 408 | const size_t back_shift{static_cast<size_t>(shift) + static_cast<size_t>(count)}; |
| 427 | if (back_shift > Common::BitSize<s32>()) { | 409 | if (back_shift > Common::BitSize<s32>()) { |
| 428 | throw LogicError("Undefined result in {}({}, {}, {})", IR::Opcode::BitFieldSExtract, | 410 | throw LogicError("Undefined result in {}({}, {}, {})", IR::Opcode::BitFieldSExtract, |
| 429 | base, shift, count); | 411 | base, shift, count); |
| 430 | } | 412 | } |
| 431 | const size_t left_shift = Common::BitSize<s32>() - back_shift; | 413 | const size_t left_shift{Common::BitSize<s32>() - back_shift}; |
| 432 | return static_cast<u32>(static_cast<s32>(base << left_shift) >> | 414 | return static_cast<u32>(static_cast<s32>(base << left_shift) >> |
| 433 | static_cast<size_t>(Common::BitSize<s32>() - count)); | 415 | static_cast<size_t>(Common::BitSize<s32>() - count)); |
| 434 | }); | 416 | }); |