diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2017-06-14 06:28:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-14 06:28:12 +0200 |
commit | 5fe5ccac4250d5f001cc29838033e2fef63ebb6c (patch) | |
tree | 32224370753184eeca64cf9b055351ee599c9e94 /src/video_core/swrasterizer/texturing.cpp | |
parent | Services/UDS: Set the proper bit in the ConnectionStatus structure when creating a network. (#2738) (diff) | |
parent | pica/rasterizer: implement/stub texture wrap mode 4-7 (diff) | |
download | yuzu-5fe5ccac4250d5f001cc29838033e2fef63ebb6c.tar yuzu-5fe5ccac4250d5f001cc29838033e2fef63ebb6c.tar.gz yuzu-5fe5ccac4250d5f001cc29838033e2fef63ebb6c.tar.bz2 yuzu-5fe5ccac4250d5f001cc29838033e2fef63ebb6c.tar.lz yuzu-5fe5ccac4250d5f001cc29838033e2fef63ebb6c.tar.xz yuzu-5fe5ccac4250d5f001cc29838033e2fef63ebb6c.tar.zst yuzu-5fe5ccac4250d5f001cc29838033e2fef63ebb6c.zip |
Diffstat (limited to 'src/video_core/swrasterizer/texturing.cpp')
-rw-r--r-- | src/video_core/swrasterizer/texturing.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/video_core/swrasterizer/texturing.cpp b/src/video_core/swrasterizer/texturing.cpp index aeb6aeb8c..4f02b93f2 100644 --- a/src/video_core/swrasterizer/texturing.cpp +++ b/src/video_core/swrasterizer/texturing.cpp @@ -18,22 +18,33 @@ using TevStageConfig = TexturingRegs::TevStageConfig; int GetWrappedTexCoord(TexturingRegs::TextureConfig::WrapMode mode, int val, unsigned size) { switch (mode) { + case TexturingRegs::TextureConfig::ClampToEdge2: + // For negative coordinate, ClampToEdge2 behaves the same as Repeat + if (val < 0) { + return static_cast<int>(static_cast<unsigned>(val) % size); + } + // [[fallthrough]] case TexturingRegs::TextureConfig::ClampToEdge: val = std::max(val, 0); - val = std::min(val, (int)size - 1); + val = std::min(val, static_cast<int>(size) - 1); return val; case TexturingRegs::TextureConfig::ClampToBorder: return val; + case TexturingRegs::TextureConfig::ClampToBorder2: + // For ClampToBorder2, the case of positive coordinate beyond the texture size is already + // handled outside. Here we only handle the negative coordinate in the same way as Repeat. + case TexturingRegs::TextureConfig::Repeat2: + case TexturingRegs::TextureConfig::Repeat3: case TexturingRegs::TextureConfig::Repeat: - return (int)((unsigned)val % size); + return static_cast<int>(static_cast<unsigned>(val) % size); case TexturingRegs::TextureConfig::MirroredRepeat: { - unsigned int coord = ((unsigned)val % (2 * size)); + unsigned int coord = (static_cast<unsigned>(val) % (2 * size)); if (coord >= size) coord = 2 * size - 1 - coord; - return (int)coord; + return static_cast<int>(coord); } default: |