mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 21:39:52 +00:00
Fix smoothed CLUT lookups. Shouldn't go beyond the mask's reach.
Should help #15896
This commit is contained in:
parent
20bd1c26d5
commit
67c911d13f
@ -288,7 +288,7 @@ void GenerateDepalShaderFloat(ShaderWriter &writer, const DepalConfig &config) {
|
||||
|
||||
void GenerateDepalSmoothed(ShaderWriter &writer, const DepalConfig &config) {
|
||||
const char *sourceChannel = "error";
|
||||
float indexMultiplier = 32.0f;
|
||||
float indexMultiplier = 31.0f;
|
||||
|
||||
if (config.bufferFormat == GE_FORMAT_5551) {
|
||||
_dbg_assert_(config.mask == 0x1F);
|
||||
@ -302,7 +302,7 @@ void GenerateDepalSmoothed(ShaderWriter &writer, const DepalConfig &config) {
|
||||
_dbg_assert_(config.mask == 0x1F || config.mask == 0x3F);
|
||||
switch (config.shift) {
|
||||
case 0: sourceChannel = "r"; break;
|
||||
case 5: sourceChannel = "g"; indexMultiplier = 64.0f; break;
|
||||
case 5: sourceChannel = "g"; indexMultiplier = 63.0f; break;
|
||||
case 11: sourceChannel = "b"; break;
|
||||
default: _dbg_assert_(false);
|
||||
}
|
||||
@ -311,7 +311,6 @@ void GenerateDepalSmoothed(ShaderWriter &writer, const DepalConfig &config) {
|
||||
}
|
||||
|
||||
writer.C(" float index = ").SampleTexture2D("tex", "v_texcoord").F(".%s * %0.1f;\n", sourceChannel, indexMultiplier);
|
||||
|
||||
float texturePixels = 256.f;
|
||||
if (config.clutFormat != GE_CMODE_32BIT_ABGR8888) {
|
||||
texturePixels = 512.f;
|
||||
|
@ -605,13 +605,15 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
|
||||
// Restrictions on this are checked before setting the smoothed flag.
|
||||
// Only RGB565 and RGBA5551 are supported, and only the specific shifts hitting the
|
||||
// channels directly.
|
||||
// Also, since we know the CLUT is smooth, we do not need to do the bilinear filter manually, we can just
|
||||
// lookup with the filtered value once.
|
||||
WRITE(p, " vec4 t = %s(tex, %s.xy);\n", compat.texture, texcoord);
|
||||
WRITE(p, " uint depalShift = (u_depal_mask_shift_off_fmt >> 8) & 0xFFU;\n");
|
||||
WRITE(p, " uint depalFmt = (u_depal_mask_shift_off_fmt >> 24) & 0x3U;\n");
|
||||
WRITE(p, " float index0 = t.r;\n");
|
||||
WRITE(p, " float factor = 32.0 / 256.0;\n");
|
||||
WRITE(p, " float factor = 31.0 / 256.0;\n");
|
||||
WRITE(p, " if (depalFmt == 0u) {\n"); // yes, different versions of Test Drive use different formats. Could do compile time by adding more compat flags but meh.
|
||||
WRITE(p, " if (depalShift == 5u) { index0 = t.g; factor = 64.0 / 256.0; }\n");
|
||||
WRITE(p, " if (depalShift == 5u) { index0 = t.g; factor = 63.0 / 256.0; }\n");
|
||||
WRITE(p, " else if (depalShift == 11u) { index0 = t.b; }\n");
|
||||
WRITE(p, " } else {\n");
|
||||
WRITE(p, " if (depalShift == 5u) { index0 = t.g; }\n");
|
||||
|
Loading…
Reference in New Issue
Block a user