diff options
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; | |||
| 18 | 18 | ||
| 19 | int GetWrappedTexCoord(TexturingRegs::TextureConfig::WrapMode mode, int val, unsigned size) { | 19 | int GetWrappedTexCoord(TexturingRegs::TextureConfig::WrapMode mode, int val, unsigned size) { |
| 20 | switch (mode) { | 20 | switch (mode) { |
| 21 | case TexturingRegs::TextureConfig::ClampToEdge2: | ||
| 22 | // For negative coordinate, ClampToEdge2 behaves the same as Repeat | ||
| 23 | if (val < 0) { | ||
| 24 | return static_cast<int>(static_cast<unsigned>(val) % size); | ||
| 25 | } | ||
| 26 | // [[fallthrough]] | ||
| 21 | case TexturingRegs::TextureConfig::ClampToEdge: | 27 | case TexturingRegs::TextureConfig::ClampToEdge: |
| 22 | val = std::max(val, 0); | 28 | val = std::max(val, 0); |
| 23 | val = std::min(val, (int)size - 1); | 29 | val = std::min(val, static_cast<int>(size) - 1); |
| 24 | return val; | 30 | return val; |
| 25 | 31 | ||
| 26 | case TexturingRegs::TextureConfig::ClampToBorder: | 32 | case TexturingRegs::TextureConfig::ClampToBorder: |
| 27 | return val; | 33 | return val; |
| 28 | 34 | ||
| 35 | case TexturingRegs::TextureConfig::ClampToBorder2: | ||
| 36 | // For ClampToBorder2, the case of positive coordinate beyond the texture size is already | ||
| 37 | // handled outside. Here we only handle the negative coordinate in the same way as Repeat. | ||
| 38 | case TexturingRegs::TextureConfig::Repeat2: | ||
| 39 | case TexturingRegs::TextureConfig::Repeat3: | ||
| 29 | case TexturingRegs::TextureConfig::Repeat: | 40 | case TexturingRegs::TextureConfig::Repeat: |
| 30 | return (int)((unsigned)val % size); | 41 | return static_cast<int>(static_cast<unsigned>(val) % size); |
| 31 | 42 | ||
| 32 | case TexturingRegs::TextureConfig::MirroredRepeat: { | 43 | case TexturingRegs::TextureConfig::MirroredRepeat: { |
| 33 | unsigned int coord = ((unsigned)val % (2 * size)); | 44 | unsigned int coord = (static_cast<unsigned>(val) % (2 * size)); |
| 34 | if (coord >= size) | 45 | if (coord >= size) |
| 35 | coord = 2 * size - 1 - coord; | 46 | coord = 2 * size - 1 - coord; |
| 36 | return (int)coord; | 47 | return static_cast<int>(coord); |
| 37 | } | 48 | } |
| 38 | 49 | ||
| 39 | default: | 50 | default: |