From 6ca752ccbc7c59dab66f476ca02d3b53527c57da Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sat, 3 Jan 2015 13:33:57 +0100 Subject: Pica/TextureUnit: Implement mirrored repeating texture wrapping. --- src/video_core/pica.h | 5 +++-- src/video_core/rasterizer.cpp | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/video_core/pica.h b/src/video_core/pica.h index ef9809d57..c20bf99d4 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h @@ -118,8 +118,9 @@ struct Regs { struct TextureConfig { enum WrapMode : u32 { - ClampToEdge = 0, - Repeat = 2, + ClampToEdge = 0, + Repeat = 2, + MirroredRepeat = 3, }; INSERT_PADDING_WORDS(0x1); diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index 65dddb47c..f788122d8 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp @@ -251,7 +251,15 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0, return val; case Regs::TextureConfig::Repeat: - return (int)(((unsigned)val) % size); + return (int)((unsigned)val % size); + + case Regs::TextureConfig::MirroredRepeat: + { + int val = (int)((unsigned)val % (2 * size)); + if (val >= size) + val = 2 * size - 1 - val; + return val; + } default: LOG_ERROR(HW_GPU, "Unknown texture coordinate wrapping mode %x\n", (int)mode); -- cgit v1.2.3