diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp index ce7f907bed..1d2e01b8f2 100644 --- a/Source/Core/VideoCommon/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/TextureConversionShader.cpp @@ -87,7 +87,6 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) WRITE(p, "{\n" " int2 sampleUv;\n" " int2 uv1 = int2(gl_FragCoord.xy);\n" - " float2 uv0 = float2(0.0, 0.0);\n" ); WRITE(p, " int y_block_position = uv1.y & %d;\n", ~(blkH - 1)); @@ -105,19 +104,21 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) WRITE(p, " sampleUv.x = x_offset_in_block + x_block_position;\n"); WRITE(p, " sampleUv.y = y_block_position + y_offset;\n"); + + WRITE(p, " float2 uv0 = float2(sampleUv);\n"); // sampleUv is the sample position in (int)gx_coords + WRITE(p, " uv0 += float2(0.5, 0.5);\n"); // move to center of pixel + WRITE(p, " uv0 *= float(position.w);\n"); // scale by two if needed (this will move to pixels border to filter linear) + WRITE(p, " uv0 += float2(position.xy);\n"); // move to copyed rect + WRITE(p, " uv0 /= float2(%d, %d);\n", EFB_WIDTH, EFB_HEIGHT); // normlize to [0:1] + WRITE(p, " uv0.y = 1.0-uv0.y;\n"); // ogl foo (disable this line for d3d) + + WRITE(p, " float sample_offset = position.w / float(%d);\n", EFB_WIDTH); } void WriteSampleColor(char*& p, const char* colorComp, const char* dest, int xoffset, API_TYPE ApiType) { - WRITE(p, // sampleUv is the sample position in (int)gx_coords - "uv0 = float2(sampleUv + int2(%d, 0));\n" // pixel offset (if more than one pixel is samped) - "uv0 += float2(0.5, 0.5);\n" // move to center of pixel - "uv0 *= float(position.w);\n" // scale by two if needed (this will move to pixels border to filter linear) - "uv0 += float2(position.xy);\n" // move to copyed rect - "uv0 /= float2(%d, %d);\n" // normlize to [0:1] - "uv0.y = 1.0-uv0.y;\n" // ogl foo (disable this line for d3d) - "%s = texture(samp0, uv0).%s;\n", - xoffset, EFB_WIDTH, EFB_HEIGHT, dest, colorComp + WRITE(p, " %s = texture(samp0, uv0 + float2(%d, 0) * sample_offset).%s;\n", + dest, xoffset, colorComp ); }