diff options
| author | degasus <wickmarkus@web.de> | 2014-02-24 16:15:44 +0100 |
|---|---|---|
| committer | degasus <wickmarkus@web.de> | 2014-02-26 11:37:29 +0100 |
| commit | 8a4aa8c1f5ff0db2b531405bb087c1f53d2da4be (patch) | |
| tree | dfb9d41bb1b62affad7b17601bb4e5329423e224 /Source/Core/VideoCommon/TextureConversionShader.cpp | |
| parent | bd3beeb1843be807629bf9680fe7d27497606801 (diff) | |
Rewrite texture tiling implementation
inline halfxb
So we know which is the first pixel by masking.
inline xl
inline xb a bit
inline yl
inline uv1.x shift
remove likely wrong guessed ternary operator
add pixel layout comment
inline xel
optimize the shifts a bit
inline xb
optimize shifts in a second step
extract xb
rename all variables
calculate cache line by position.x
Revert 5115b459f40d53044cd7a858f52e6e876e1211b4 "optimize the shifts a bit"
It seems I was wrong, the other way is the more natural.
use x_virtual_position instead of uv1.x for x_offset_in_block
This looks more natural and the offset should be masked anyway.
substitude factor with cache_lines
move 32bit logic in a conditional block
Diffstat (limited to 'Source/Core/VideoCommon/TextureConversionShader.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/TextureConversionShader.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp index 0fca9df552..c85c028b93 100644 --- a/Source/Core/VideoCommon/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/TextureConversionShader.cpp @@ -66,8 +66,7 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) int blkW = TexDecoder_GetBlockWidthInTexels(format); int blkH = TexDecoder_GetBlockHeightInTexels(format); int samples = GetEncodedSampleCount(format); - // 32 bit textures (RGBA8 and Z24) are store in 2 cache line increments - int factor = samples == 1 ? 2 : 1; + if (ApiType == API_OPENGL) { WRITE(p, "#define samp0 samp9\n"); @@ -91,22 +90,21 @@ 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", Log2(samples)); - - WRITE(p, " int yl = uv1.y >> %d;\n", Log2(blkH)); - WRITE(p, " int yb = yl << %d;\n", Log2(blkH)); - WRITE(p, " int yoff = uv1.y - yb;\n"); - WRITE(p, " int xp = uv1.x + yoff * position.z;\n"); - WRITE(p, " int xel = xp >> %d;\n", Log2(samples == 1 ? factor : blkW)); - WRITE(p, " int xb = xel >> %d;\n", Log2(blkH)); - WRITE(p, " int xoff = xel - (xb << %d);\n", Log2(blkH)); - WRITE(p, " int xl = (uv1.x << %d) >> %d;\n", Log2(factor), Log2(blkW)); - WRITE(p, " int xib = (uv1.x << %d) - (xl << %d);\n", Log2(factor), Log2(blkW)); - WRITE(p, " int halfxb = xb >> %d;\n", Log2(factor)); - - WRITE(p, " sampleUv.x = xib + (halfxb << %d);\n", Log2(blkW)); - WRITE(p, " sampleUv.y = yb + xoff;\n"); - WRITE(p, " bool first = xb == (halfxb << 1);\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 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); + 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, " sampleUv.x = x_offset_in_block + x_block_position;\n"); + WRITE(p, " sampleUv.y = y_block_position + y_offset;\n"); } void WriteSampleColor(char*& p, const char* colorComp, const char* dest, int xoffset, API_TYPE ApiType) |
