diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index 02109b88fd..99e9f702c7 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -75,9 +75,9 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) // Two were merged for GLSL WRITE(p, "uniform float4 " I_COLORS"[2] %s;\n", WriteRegister(ApiType, "c", C_COLORS)); - float blkW = (float)TexDecoder_GetBlockWidthInTexels(format); - float blkH = (float)TexDecoder_GetBlockHeightInTexels(format); - float samples = (float)GetEncodedSampleCount(format); + int blkW = TexDecoder_GetBlockWidthInTexels(format); + int blkH = TexDecoder_GetBlockHeightInTexels(format); + int samples = GetEncodedSampleCount(format); if (ApiType == API_OPENGL) { WRITE(p, "#define samp0 samp9\n"); @@ -101,19 +101,19 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) " float2 sampleUv;\n" " float2 uv1 = floor(uv0);\n"); - WRITE(p, " uv1.x = uv1.x * %f;\n", samples); + WRITE(p, " uv1.x = uv1.x * %d.0;\n", samples); - WRITE(p, " float xl = floor(uv1.x / %f);\n", blkW); - WRITE(p, " float xib = uv1.x - (xl * %f);\n", blkW); - WRITE(p, " float yl = floor(uv1.y / %f);\n", blkH); - WRITE(p, " float yb = yl * %f;\n", blkH); + WRITE(p, " float xl = floor(uv1.x / %d.0);\n", blkW); + WRITE(p, " float xib = uv1.x - (xl * %d.0);\n", blkW); + WRITE(p, " float yl = floor(uv1.y / %d.0);\n", blkH); + WRITE(p, " float yb = yl * %d.0;\n", blkH); WRITE(p, " float yoff = uv1.y - yb;\n"); WRITE(p, " float xp = uv1.x + (yoff * " I_COLORS"[1].x);\n"); - WRITE(p, " float xel = floor(xp / %f);\n", blkW); - WRITE(p, " float xb = floor(xel / %f);\n", blkH); - WRITE(p, " float xoff = xel - (xb * %f);\n", blkH); + WRITE(p, " float xel = floor(xp / %d.0);\n", blkW); + WRITE(p, " float xb = floor(xel / %d.0);\n", blkH); + WRITE(p, " float xoff = xel - (xb * %d.0);\n", blkH); - WRITE(p, " sampleUv.x = xib + (xb * %f);\n", blkW); + WRITE(p, " sampleUv.x = xib + (xb * %d.0);\n", blkW); WRITE(p, " sampleUv.y = yb + xoff;\n"); WRITE(p, " sampleUv = sampleUv * " I_COLORS"[0].xy;\n"); @@ -139,8 +139,8 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType) // Two were merged for GLSL WRITE(p, "uniform float4 " I_COLORS"[2] %s;\n", WriteRegister(ApiType, "c", C_COLORS)); - float blkW = (float)TexDecoder_GetBlockWidthInTexels(format); - float blkH = (float)TexDecoder_GetBlockHeightInTexels(format); + int blkW = TexDecoder_GetBlockWidthInTexels(format); + int blkH = TexDecoder_GetBlockHeightInTexels(format); // 32 bit textures (RGBA8 and Z24) are store in 2 cache line increments if (ApiType == API_OPENGL) @@ -167,20 +167,20 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType) " float2 sampleUv;\n" " float2 uv1 = floor(uv0);\n"); - WRITE(p, " float yl = floor(uv1.y / %f);\n", blkH); - WRITE(p, " float yb = yl * %f;\n", blkH); + WRITE(p, " float yl = floor(uv1.y / %d.0);\n", blkH); + WRITE(p, " float yb = yl * %d.0;\n", blkH); WRITE(p, " float yoff = uv1.y - yb;\n"); WRITE(p, " float xp = uv1.x + (yoff * " I_COLORS"[1].x);\n"); WRITE(p, " float xel = floor(xp / 2.0);\n"); - WRITE(p, " float xb = floor(xel / %f);\n", blkH); - WRITE(p, " float xoff = xel - (xb * %f);\n", blkH); + WRITE(p, " float xb = floor(xel / %d.0);\n", blkH); + WRITE(p, " float xoff = xel - (xb * %d.0);\n", blkH); WRITE(p, " float x2 = uv1.x * 2.0;\n"); - WRITE(p, " float xl = floor(x2 / %f);\n", blkW); - WRITE(p, " float xib = x2 - (xl * %f);\n", blkW); + WRITE(p, " float xl = floor(x2 / %d.0);\n", blkW); + WRITE(p, " float xib = x2 - (xl * %d.0);\n", blkW); WRITE(p, " float halfxb = floor(xb / 2.0);\n"); - WRITE(p, " sampleUv.x = xib + (halfxb * %f);\n", blkW); + WRITE(p, " sampleUv.x = xib + (halfxb * %d.0);\n", blkW); WRITE(p, " sampleUv.y = yb + xoff;\n"); WRITE(p, " sampleUv = sampleUv * " I_COLORS"[0].xy;\n"); @@ -247,8 +247,7 @@ void WriteIncrementSampleX(char*& p,API_TYPE ApiType) void WriteToBitDepth(char*& p, u8 depth, const char* src, const char* dest) { - float result = 255 / pow(2.0, (8 - depth)); - WRITE(p, " %s = floor(%s * %ff);\n", dest, src, result); + WRITE(p, " %s = floor(%s * 255.0 / exp2(8.0 - %d.0));\n", dest, src, depth); } void WriteEncoderEnd(char* p, API_TYPE ApiType)