diff options
| author | Connor McLaughlin <stenzek@gmail.com> | 2019-08-04 14:39:38 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-04 14:39:38 +1000 |
| commit | 7de6b57c13235a56ddda024ae46f76e88170522f (patch) | |
| tree | ee2585bf7831b4b0cf6508760116979a4ad14a4f /Source/Core/VideoCommon/RenderState.cpp | |
| parent | c829351c90f8f9833a0a311c7982603c0c1339c9 (diff) | |
| parent | f6f9dc0cacb0dcbbd09d31acbb6e3a3ece764541 (diff) | |
Merge pull request #8284 from stenzek/logic-op-hack
RenderState: Approximate logic op with blending if unsupported
Diffstat (limited to 'Source/Core/VideoCommon/RenderState.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/RenderState.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/RenderState.cpp b/Source/Core/VideoCommon/RenderState.cpp index 04d8804f0c..6d6f892979 100644 --- a/Source/Core/VideoCommon/RenderState.cpp +++ b/Source/Core/VideoCommon/RenderState.cpp @@ -167,6 +167,42 @@ void BlendingState::Generate(const BPMemory& bp) } } +void BlendingState::ApproximateLogicOpWithBlending() +{ + // Any of these which use SRC as srcFactor or DST as dstFactor won't be correct. + // This is because the two are aliased to one another (see the enum). + struct LogicOpApproximation + { + bool subtract; + BlendMode::BlendFactor srcfactor; + BlendMode::BlendFactor dstfactor; + }; + static constexpr std::array<LogicOpApproximation, 16> approximations = {{ + {false, BlendMode::ZERO, BlendMode::ZERO}, // CLEAR + {false, BlendMode::DSTCLR, BlendMode::ZERO}, // AND + {true, BlendMode::ONE, BlendMode::INVSRCCLR}, // AND_REVERSE + {false, BlendMode::ONE, BlendMode::ZERO}, // COPY + {true, BlendMode::DSTCLR, BlendMode::ONE}, // AND_INVERTED + {false, BlendMode::ZERO, BlendMode::ONE}, // NOOP + {false, BlendMode::INVDSTCLR, BlendMode::INVSRCCLR}, // XOR + {false, BlendMode::INVDSTCLR, BlendMode::ONE}, // OR + {false, BlendMode::INVSRCCLR, BlendMode::INVDSTCLR}, // NOR + {false, BlendMode::INVSRCCLR, BlendMode::ZERO}, // EQUIV + {false, BlendMode::INVDSTCLR, BlendMode::INVDSTCLR}, // INVERT + {false, BlendMode::ONE, BlendMode::INVDSTALPHA}, // OR_REVERSE + {false, BlendMode::INVSRCCLR, BlendMode::INVSRCCLR}, // COPY_INVERTED + {false, BlendMode::INVSRCCLR, BlendMode::ONE}, // OR_INVERTED + {false, BlendMode::INVDSTCLR, BlendMode::INVSRCCLR}, // NAND + {false, BlendMode::ONE, BlendMode::ONE}, // SET + }}; + + logicopenable = false; + blendenable = true; + subtract = approximations[logicmode].subtract; + srcfactor = approximations[logicmode].srcfactor; + dstfactor = approximations[logicmode].dstfactor; +} + BlendingState& BlendingState::operator=(const BlendingState& rhs) { hex = rhs.hex; |
