diff options
| author | Stenzek <stenzek@gmail.com> | 2016-01-14 01:57:01 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2016-01-15 19:46:38 +1000 |
| commit | edebadc0936c13de5c70b149fd99cfea684d4adc (patch) | |
| tree | 2d45e85539f5d31ad26e7982d4243980356de747 /Source/Core | |
| parent | 87464d432b8dbef6311ee827d592cdce84fe7b67 (diff) | |
PixelShaderGen: Use bitwise AND for wrapping indirect texture coordinates
(x % y) is not defined in GLSL when sign(x) != sign(y).
This also has the added benefit of behaving the same as sampler wrapping modes, in regards to negative inputs.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/VideoBackends/Software/Tev.cpp | 10 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderGen.cpp | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/Source/Core/VideoBackends/Software/Tev.cpp b/Source/Core/VideoBackends/Software/Tev.cpp index 939b9f98a4..a09b9cbb00 100644 --- a/Source/Core/VideoBackends/Software/Tev.cpp +++ b/Source/Core/VideoBackends/Software/Tev.cpp @@ -374,15 +374,15 @@ static inline s32 WrapIndirectCoord(s32 coord, int wrapMode) case ITW_OFF: return coord; case ITW_256: - return (coord % (256 << 7)); + return (coord & ((256 << 7) - 1)); case ITW_128: - return (coord % (128 << 7)); + return (coord & ((128 << 7) - 1)); case ITW_64: - return (coord % (64 << 7)); + return (coord & ((64 << 7) - 1)); case ITW_32: - return (coord % (32 << 7)); + return (coord & ((32 << 7) - 1)); case ITW_16: - return (coord % (16 << 7)); + return (coord & ((16 << 7) - 1)); case ITW_0: return 0; default: diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index 04c0df00c6..9b4cc8f46f 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -764,7 +764,7 @@ static void WriteStage(T& out, pixel_shader_uid_data* uid_data, int n, API_TYPE else if (bpmem.tevind[n].sw == ITW_0) out.Write("\twrappedcoord.x = 0;\n"); else - out.Write("\twrappedcoord.x = fixpoint_uv%d.x %% %s;\n", texcoord, tevIndWrapStart[bpmem.tevind[n].sw]); + out.Write("\twrappedcoord.x = fixpoint_uv%d.x & (%s - 1);\n", texcoord, tevIndWrapStart[bpmem.tevind[n].sw]); // wrap T if (bpmem.tevind[n].tw == ITW_OFF) @@ -772,7 +772,7 @@ static void WriteStage(T& out, pixel_shader_uid_data* uid_data, int n, API_TYPE else if (bpmem.tevind[n].tw == ITW_0) out.Write("\twrappedcoord.y = 0;\n"); else - out.Write("\twrappedcoord.y = fixpoint_uv%d.y %% %s;\n", texcoord, tevIndWrapStart[bpmem.tevind[n].tw]); + out.Write("\twrappedcoord.y = fixpoint_uv%d.y & (%s - 1);\n", texcoord, tevIndWrapStart[bpmem.tevind[n].tw]); if (bpmem.tevind[n].fb_addprev) // add previous tevcoord out.Write("\ttevcoord.xy += wrappedcoord + indtevtrans%d;\n", n); |
