summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/TextureConversionShader.cpp
diff options
context:
space:
mode:
authorLinktothepast <kostamarino@gmail.com>2015-09-28 16:50:35 +0300
committerLinktothepast <kostamarino@gmail.com>2015-09-28 16:50:35 +0300
commit748be565b8df535ef558e74b38cd0f4d615f8a21 (patch)
treeb151efee0a87e99125f2401325a9bddecf84fc73 /Source/Core/VideoCommon/TextureConversionShader.cpp
parentcf17fccdd3093a1b8476b10183b1c4bde36da74d (diff)
parentce493b897d6d3735c930a8465cc0c26bbe5feb86 (diff)
Merge remote-tracking branch 'dolphin-emu/master' into gameinis
Diffstat (limited to 'Source/Core/VideoCommon/TextureConversionShader.cpp')
-rw-r--r--Source/Core/VideoCommon/TextureConversionShader.cpp44
1 files changed, 23 insertions, 21 deletions
diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp
index f93d465a16..033a56b4aa 100644
--- a/Source/Core/VideoCommon/TextureConversionShader.cpp
+++ b/Source/Core/VideoCommon/TextureConversionShader.cpp
@@ -148,7 +148,7 @@ static void WriteToBitDepth(char*& p, u8 depth, const char* src, const char* des
WRITE(p, " %s = floor(%s * 255.0 / exp2(8.0 - %d.0));\n", dest, src, depth);
}
-static void WriteEncoderEnd(char*& p, API_TYPE ApiType)
+static void WriteEncoderEnd(char*& p)
{
WRITE(p, "}\n");
IntensityConstantAdded = false;
@@ -173,7 +173,7 @@ static void WriteI8Encoder(char*& p, API_TYPE ApiType)
WRITE(p, " ocol0.rgba += IntensityConst.aaaa;\n"); // see WriteColorToIntensity
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
static void WriteI4Encoder(char*& p, API_TYPE ApiType)
@@ -214,7 +214,7 @@ static void WriteI4Encoder(char*& p, API_TYPE ApiType)
WriteToBitDepth(p, 4, "color1", "color1");
WRITE(p, " ocol0 = (color0 * 16.0 + color1) / 255.0;\n");
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
static void WriteIA8Encoder(char*& p,API_TYPE ApiType)
@@ -232,7 +232,7 @@ static void WriteIA8Encoder(char*& p,API_TYPE ApiType)
WRITE(p, " ocol0.ga += IntensityConst.aa;\n");
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
static void WriteIA4Encoder(char*& p,API_TYPE ApiType)
@@ -264,7 +264,7 @@ static void WriteIA4Encoder(char*& p,API_TYPE ApiType)
WriteToBitDepth(p, 4, "color1", "color1");
WRITE(p, " ocol0 = (color0 * 16.0 + color1) / 255.0;\n");
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
static void WriteRGB565Encoder(char*& p,API_TYPE ApiType)
@@ -287,7 +287,7 @@ static void WriteRGB565Encoder(char*& p,API_TYPE ApiType)
WRITE(p, " ocol0.ga = ocol0.ga + gLower * 32.0;\n");
WRITE(p, " ocol0 = ocol0 / 255.0;\n");
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
static void WriteRGB5A3Encoder(char*& p,API_TYPE ApiType)
@@ -353,7 +353,7 @@ static void WriteRGB5A3Encoder(char*& p,API_TYPE ApiType)
WRITE(p, "}\n");
WRITE(p, " ocol0 = ocol0 / 255.0;\n");
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
static void WriteRGBA8Encoder(char*& p,API_TYPE ApiType)
@@ -378,7 +378,7 @@ static void WriteRGBA8Encoder(char*& p,API_TYPE ApiType)
WRITE(p, " ocol0 = first ? color0 : color1;\n");
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
static void WriteC4Encoder(char*& p, const char* comp,API_TYPE ApiType)
@@ -400,7 +400,7 @@ static void WriteC4Encoder(char*& p, const char* comp,API_TYPE ApiType)
WriteToBitDepth(p, 4, "color1", "color1");
WRITE(p, " ocol0 = (color0 * 16.0 + color1) / 255.0;\n");
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
static void WriteC8Encoder(char*& p, const char* comp,API_TYPE ApiType)
@@ -412,7 +412,7 @@ static void WriteC8Encoder(char*& p, const char* comp,API_TYPE ApiType)
WriteSampleColor(p, comp, "ocol0.r", 2, ApiType);
WriteSampleColor(p, comp, "ocol0.a", 3, ApiType);
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
static void WriteCC4Encoder(char*& p, const char* comp,API_TYPE ApiType)
@@ -442,7 +442,7 @@ static void WriteCC4Encoder(char*& p, const char* comp,API_TYPE ApiType)
WriteToBitDepth(p, 4, "color1", "color1");
WRITE(p, " ocol0 = (color0 * 16.0 + color1) / 255.0;\n");
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
static void WriteCC8Encoder(char*& p, const char* comp, API_TYPE ApiType)
@@ -452,7 +452,7 @@ static void WriteCC8Encoder(char*& p, const char* comp, API_TYPE ApiType)
WriteSampleColor(p, comp, "ocol0.bg", 0, ApiType);
WriteSampleColor(p, comp, "ocol0.ra", 1, ApiType);
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
static void WriteZ8Encoder(char*& p, const char* multiplier,API_TYPE ApiType)
@@ -477,7 +477,7 @@ static void WriteZ8Encoder(char*& p, const char* multiplier,API_TYPE ApiType)
if (ApiType == API_D3D) WRITE(p, "depth = 1.0f - depth;\n");
WRITE(p, "ocol0.a = frac(depth * %s);\n", multiplier);
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
static void WriteZ16Encoder(char*& p,API_TYPE ApiType)
@@ -492,7 +492,7 @@ static void WriteZ16Encoder(char*& p,API_TYPE ApiType)
WriteSampleColor(p, "r", "depth", 0, ApiType);
if (ApiType == API_D3D) WRITE(p, "depth = 1.0f - depth;\n");
- WRITE(p, " depth = clamp(depth * 16777216.0, 0.0, float(0xFFFFFF));\n");
+ WRITE(p, " depth *= 16777216.0;\n");
WRITE(p, " expanded.r = floor(depth / (256.0 * 256.0));\n");
WRITE(p, " depth -= expanded.r * 256.0 * 256.0;\n");
WRITE(p, " expanded.g = floor(depth / 256.0);\n");
@@ -503,7 +503,7 @@ static void WriteZ16Encoder(char*& p,API_TYPE ApiType)
WriteSampleColor(p, "r", "depth", 1, ApiType);
if (ApiType == API_D3D) WRITE(p, "depth = 1.0f - depth;\n");
- WRITE(p, " depth = clamp(depth * 16777216.0, 0.0, float(0xFFFFFF));\n");
+ WRITE(p, " depth *= 16777216.0;\n");
WRITE(p, " expanded.r = floor(depth / (256.0 * 256.0));\n");
WRITE(p, " depth -= expanded.r * 256.0 * 256.0;\n");
WRITE(p, " expanded.g = floor(depth / 256.0);\n");
@@ -511,7 +511,7 @@ static void WriteZ16Encoder(char*& p,API_TYPE ApiType)
WRITE(p, " ocol0.r = expanded.g / 255.0;\n");
WRITE(p, " ocol0.a = expanded.r / 255.0;\n");
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
static void WriteZ16LEncoder(char*& p,API_TYPE ApiType)
@@ -526,7 +526,7 @@ static void WriteZ16LEncoder(char*& p,API_TYPE ApiType)
WriteSampleColor(p, "r", "depth", 0, ApiType);
if (ApiType == API_D3D) WRITE(p, "depth = 1.0f - depth;\n");
- WRITE(p, " depth = clamp(depth * 16777216.0, 0.0, float(0xFFFFFF));\n");
+ WRITE(p, " depth *= 16777216.0;\n");
WRITE(p, " expanded.r = floor(depth / (256.0 * 256.0));\n");
WRITE(p, " depth -= expanded.r * 256.0 * 256.0;\n");
WRITE(p, " expanded.g = floor(depth / 256.0);\n");
@@ -539,7 +539,7 @@ static void WriteZ16LEncoder(char*& p,API_TYPE ApiType)
WriteSampleColor(p, "r", "depth", 1, ApiType);
if (ApiType == API_D3D) WRITE(p, "depth = 1.0f - depth;\n");
- WRITE(p, " depth = clamp(depth * 16777216.0, 0.0, float(0xFFFFFF));\n");
+ WRITE(p, " depth *= 16777216.0;\n");
WRITE(p, " expanded.r = floor(depth / (256.0 * 256.0));\n");
WRITE(p, " depth -= expanded.r * 256.0 * 256.0;\n");
WRITE(p, " expanded.g = floor(depth / 256.0);\n");
@@ -549,7 +549,7 @@ static void WriteZ16LEncoder(char*& p,API_TYPE ApiType)
WRITE(p, " ocol0.r = expanded.b / 255.0;\n");
WRITE(p, " ocol0.a = expanded.g / 255.0;\n");
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
static void WriteZ24Encoder(char*& p, API_TYPE ApiType)
@@ -568,7 +568,7 @@ static void WriteZ24Encoder(char*& p, API_TYPE ApiType)
for (int i = 0; i < 2; i++)
{
- WRITE(p, " depth%i = clamp(depth%i * 16777216.0, 0.0, float(0xFFFFFF));\n", i, i);
+ WRITE(p, " depth%i *= 16777216.0;\n", i);
WRITE(p, " expanded%i.r = floor(depth%i / (256.0 * 256.0));\n", i, i);
WRITE(p, " depth%i -= expanded%i.r * 256.0 * 256.0;\n", i, i);
@@ -591,7 +591,7 @@ static void WriteZ24Encoder(char*& p, API_TYPE ApiType)
WRITE(p, " ocol0.a = expanded1.r / 255.0;\n");
WRITE(p, " }\n");
- WriteEncoderEnd(p, ApiType);
+ WriteEncoderEnd(p);
}
const char *GenerateEncodingShader(u32 format,API_TYPE ApiType)
@@ -650,9 +650,11 @@ const char *GenerateEncodingShader(u32 format,API_TYPE ApiType)
case GX_CTF_GB8:
WriteCC8Encoder(p, "gb", ApiType);
break;
+ case GX_CTF_Z8H:
case GX_TF_Z8:
WriteC8Encoder(p, "r", ApiType);
break;
+ case GX_CTF_Z16R:
case GX_TF_Z16:
WriteZ16Encoder(p, ApiType);
break;