(view as text)
diff --git a/Source/Core/VideoBackends/OGL/TextureConverter.cpp b/Source/Core/VideoBackends/OGL/TextureConverter.cpp
index bf36523..3f0b3d2 100644
--- a/Source/Core/VideoBackends/OGL/TextureConverter.cpp
+++ b/Source/Core/VideoBackends/OGL/TextureConverter.cpp
@@ -113,7 +113,7 @@ void CreatePrograms()
" ivec2 uv = ivec2(gl_FragCoord.xy);\n"
// We switch top/bottom here. TODO: move this to screen blit.
" ivec2 ts = textureSize(samp9, 0);\n"
- " vec4 c0 = texelFetch(samp9, ivec2(uv.x/2, ts.y-uv.y-1), 0);\n"
+ " vec4 c0 = texelFetch(samp9, ivec2(uv.x>>1, ts.y-uv.y-1), 0);\n"
" float y = mix(c0.b, c0.r, (uv.x & 1) == 1);\n"
" float yComp = 1.164 * (y - 0.0625);\n"
" float uComp = c0.g - 0.5;\n"
diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp
index 209b7e4..4e98f80 100644
--- a/Source/Core/VideoCommon/TextureConversionShader.cpp
+++ b/Source/Core/VideoCommon/TextureConversionShader.cpp
@@ -15,6 +15,7 @@
#include "BPMemory.h"
#include "RenderBase.h"
#include "VideoConfig.h"
+#include "MathUtil.h"
#define WRITE p+=sprintf
@@ -91,21 +92,18 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType)
" float2 uv0 = float2(0.0, 0.0);\n"
);
- WRITE(p, " uv1.x = uv1.x * %d;\n", samples);
+ WRITE(p, " uv1.x = uv1.x << %d;\n", Log2(samples));
- WRITE(p, " int yl = uv1.y / %d;\n", blkH);
- WRITE(p, " int yb = yl * %d;\n", blkH);
- WRITE(p, " int yoff = uv1.y - yb;\n");
+ WRITE(p, " int yb = uv1.y & ~(%d - 1);\n", blkH);
+ WRITE(p, " int yoff = uv1.y & (%d - 1);\n", blkH);
WRITE(p, " int xp = uv1.x + yoff * position.z;\n");
- WRITE(p, " int xel = xp / %d;\n", samples == 1 ? factor : blkW);
- WRITE(p, " int xb = xel / %d;\n", blkH);
- WRITE(p, " int xoff = xel - xb * %d;\n", blkH);
- WRITE(p, " int xl = uv1.x * %d / %d;\n", factor, blkW);
- WRITE(p, " int xib = uv1.x * %d - xl * %d;\n", factor, blkW);
- WRITE(p, " int halfxb = xb / %d;\n", factor);
-
- WRITE(p, " sampleUv.x = xib + halfxb * %d;\n", blkW);
+ WRITE(p, " int xel = xp >> %d;\n", Log2(samples == 1 ? factor : blkW));
+ WRITE(p, " int xoff = xel & (%d - 1);\n", blkH);
+ WRITE(p, " int xib = (uv1.x << %d) & (%d - 1);\n", factor-1, blkW);
+
+ WRITE(p, " sampleUv.x = xib + (xel >> %d << %d);\n", Log2(blkH * factor), Log2(blkW));
WRITE(p, " sampleUv.y = yb + xoff;\n");
+ WRITE(p, " bool first = 0 == (uv1.x & 1);\n");
}
void WriteSampleColor(char*& p, const char* colorComp, const char* dest, int xoffset, API_TYPE ApiType)
@@ -374,8 +372,6 @@ void WriteRGBA8Encoder(char* p,API_TYPE ApiType)
{
WriteSwizzler(p, GX_TF_RGBA8, ApiType);
- WRITE(p, " bool first = xb == (halfxb * 2);\n");
-
WRITE(p, " float4 texSample;\n");
WRITE(p, " float4 color0;\n");
WRITE(p, " float4 color1;\n");
@@ -564,8 +560,6 @@ void WriteZ24Encoder(char* p, API_TYPE ApiType)
{
WriteSwizzler(p, GX_TF_Z24X8, ApiType);
- WRITE(p, " bool first = xb == (halfxb * 2);\n");
-
WRITE(p, " float depth0;\n");
WRITE(p, " float depth1;\n");
WRITE(p, " float3 expanded0;\n");