diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp index c85c028b93..ce7f907bed 100644 --- a/Source/Core/VideoCommon/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/TextureConversionShader.cpp @@ -90,18 +90,18 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) " float2 uv0 = float2(0.0, 0.0);\n" ); - WRITE(p, " int y_block_position = uv1.y & ~(%d - 1);\n", blkH); - WRITE(p, " int y_offset_in_block = uv1.y & (%d - 1);\n", blkH); + WRITE(p, " int y_block_position = uv1.y & %d;\n", ~(blkH - 1)); + WRITE(p, " int y_offset_in_block = uv1.y & %d;\n", blkH - 1); WRITE(p, " int x_virtual_position = (uv1.x << %d) + y_offset_in_block * position.z;\n", Log2(samples)); - WRITE(p, " int x_block_position = (x_virtual_position >> %d) & ~(%d - 1);\n", Log2(blkH), blkW); + WRITE(p, " int x_block_position = (x_virtual_position >> %d) & %d;\n", Log2(blkH), ~(blkW - 1)); if (samples == 1) { // 32 bit textures (RGBA8 and Z24) are store in 2 cache line increments WRITE(p, " bool first = 0 == (x_virtual_position & %d);\n", 8 * samples); // first cache line, used in the encoders WRITE(p, " x_virtual_position = x_virtual_position << 1;\n"); } - WRITE(p, " int x_offset_in_block = x_virtual_position & (%d - 1);\n", blkW); - WRITE(p, " int y_offset = (x_virtual_position >> %d) & (%d - 1);\n", Log2(blkW), blkH); + WRITE(p, " int x_offset_in_block = x_virtual_position & %d;\n", blkW - 1); + WRITE(p, " int y_offset = (x_virtual_position >> %d) & %d;\n", Log2(blkW), blkH - 1); WRITE(p, " sampleUv.x = x_offset_in_block + x_block_position;\n"); WRITE(p, " sampleUv.y = y_block_position + y_offset;\n");