summaryrefslogtreecommitdiff
path: root/src/video_core/swrasterizer
diff options
context:
space:
mode:
authorGravatar wwylele2017-06-01 16:56:46 +0300
committerGravatar wwylele2017-06-04 09:47:25 +0300
commit28d1e73d2f1eb5d77568303050d254fd3b4df853 (patch)
tree29f34273ed1a7943a5f32b6e510d6f4caf6e5c02 /src/video_core/swrasterizer
parentMerge pull request #2734 from yuriks/cmake-imported-libs (diff)
downloadyuzu-28d1e73d2f1eb5d77568303050d254fd3b4df853.tar.gz
yuzu-28d1e73d2f1eb5d77568303050d254fd3b4df853.tar.xz
yuzu-28d1e73d2f1eb5d77568303050d254fd3b4df853.zip
pica/rasterizer: implement/stub texture wrap mode 4-7
Diffstat (limited to 'src/video_core/swrasterizer')
-rw-r--r--src/video_core/swrasterizer/rasterizer.cpp20
-rw-r--r--src/video_core/swrasterizer/texturing.cpp19
2 files changed, 31 insertions, 8 deletions
diff --git a/src/video_core/swrasterizer/rasterizer.cpp b/src/video_core/swrasterizer/rasterizer.cpp
index e9edf0360..908c7bb9e 100644
--- a/src/video_core/swrasterizer/rasterizer.cpp
+++ b/src/video_core/swrasterizer/rasterizer.cpp
@@ -307,10 +307,22 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
307 int t = (int)(v * float24::FromFloat32(static_cast<float>(texture.config.height))) 307 int t = (int)(v * float24::FromFloat32(static_cast<float>(texture.config.height)))
308 .ToFloat32(); 308 .ToFloat32();
309 309
310 if ((texture.config.wrap_s == TexturingRegs::TextureConfig::ClampToBorder && 310 bool use_border_s = false;
311 (s < 0 || static_cast<u32>(s) >= texture.config.width)) || 311 bool use_border_t = false;
312 (texture.config.wrap_t == TexturingRegs::TextureConfig::ClampToBorder && 312
313 (t < 0 || static_cast<u32>(t) >= texture.config.height))) { 313 if (texture.config.wrap_s == TexturingRegs::TextureConfig::ClampToBorder) {
314 use_border_s = s < 0 || s >= static_cast<int>(texture.config.width);
315 } else if (texture.config.wrap_s == TexturingRegs::TextureConfig::ClampToBorder2) {
316 use_border_s = s >= static_cast<int>(texture.config.width);
317 }
318
319 if (texture.config.wrap_t == TexturingRegs::TextureConfig::ClampToBorder) {
320 use_border_t = t < 0 || t >= static_cast<int>(texture.config.height);
321 } else if (texture.config.wrap_t == TexturingRegs::TextureConfig::ClampToBorder2) {
322 use_border_t = t >= static_cast<int>(texture.config.height);
323 }
324
325 if (use_border_s || use_border_t) {
314 auto border_color = texture.config.border_color; 326 auto border_color = texture.config.border_color;
315 texture_color[i] = {border_color.r, border_color.g, border_color.b, 327 texture_color[i] = {border_color.r, border_color.g, border_color.b,
316 border_color.a}; 328 border_color.a};
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
19int GetWrappedTexCoord(TexturingRegs::TextureConfig::WrapMode mode, int val, unsigned size) { 19int 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: