From d41613c46ab2f1d7392af9b6e351ee57b44cf8a1 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Fri, 6 May 2016 19:57:42 +0200 Subject: [PATCH] gsdx ogl: add a Tales of Abyss HLE shader Again fast and efficient but it relies on CRC v2: forget to update the precompiled shader... --- plugins/GSdx/GSDeviceOGL.cpp | 3 ++- plugins/GSdx/GSDeviceOGL.h | 5 +++-- plugins/GSdx/GSRendererOGL.cpp | 11 ++++++++--- plugins/GSdx/res/glsl/tfx_fs.glsl | 9 ++++++++- plugins/GSdx/res/glsl_source.h | 9 ++++++++- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index ca241aa74d..2a2d5bec25 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -767,7 +767,8 @@ GLuint GSDeviceOGL::CompilePS(PSSelector sel) + format("#define PS_DFMT %d\n", sel.dfmt) + format("#define PS_DEPTH_FMT %d\n", sel.depth_fmt) + format("#define PS_CHANNEL_FETCH %d\n", sel.channel) - + format("#define PS_URBAN_CHAOS_HACK %d\n", sel.urban_chaos_hack) + + format("#define PS_URBAN_CHAOS_HLE %d\n", sel.urban_chaos_hle) + + format("#define PS_TALES_OF_ABYSS_HLE %d\n", sel.tales_of_abyss_hle) + format("#define PS_AEM %d\n", sel.aem) + format("#define PS_TFX %d\n", sel.tfx) + format("#define PS_TCC %d\n", sel.tcc) diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index d56ff8a3ba..8b83075f2f 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -289,9 +289,10 @@ class GSDeviceOGL final : public GSDevice // Hack uint32 tcoffsethack:1; - uint32 urban_chaos_hack:1; + uint32 urban_chaos_hle:1; + uint32 tales_of_abyss_hle:1; - uint32 _free2:15; + uint32 _free2:14; }; uint64 key; diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp index 26fa6a8fe4..f04a7d4349 100644 --- a/plugins/GSdx/GSRendererOGL.cpp +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -678,6 +678,14 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour ps_sel.channel = 7; m_context->TEX0.TFX = TFX_DECAL; rt = tex->m_from_target; + } else if ((tex->m_texture->GetType() == GSTexture::DepthStencil) && !(tex->m_32_bits_fmt)) { + if (m_game.title == CRC::TalesOfAbyss) { + GL_INS("Tales Of Abyss Crazyness (MSB 16b depth to Alpha)"); + ps_sel.tales_of_abyss_hle = 1; + } else { + GL_INS("Urban Chaos Crazyness (Green extraction)"); + ps_sel.urban_chaos_hle = 1; + } } else if (m_context->CLAMP.WMS == 3 && ((m_context->CLAMP.MAXU & 0x8) == 8)) { // Read either blue or Alpha. Let's go for Blue ;) // MGS3/Kill Zone @@ -688,9 +696,6 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour // Pop GL_INS("Red channel"); ps_sel.channel = 1; - } else if ((tex->m_texture->GetType() == GSTexture::DepthStencil) && !(tex->m_32_bits_fmt)) { - GL_INS("Urban Chaos Crazyness"); - ps_sel.urban_chaos_hack = 1; } else { GL_INS("channel not supported"); m_channel_shuffle = false; diff --git a/plugins/GSdx/res/glsl/tfx_fs.glsl b/plugins/GSdx/res/glsl/tfx_fs.glsl index 726b0052a5..22e4fdb71e 100644 --- a/plugins/GSdx/res/glsl/tfx_fs.glsl +++ b/plugins/GSdx/res/glsl/tfx_fs.glsl @@ -235,7 +235,14 @@ vec4 sample_depth(vec2 st) ivec2 uv = ivec2(uv_f); vec4 t; -#if PS_URBAN_CHAOS_HACK == 1 +#if PS_TALES_OF_ABYSS_HLE == 1 + // Warning: UV can't be used in channel effect + int depth = fetch_raw_depth(); + + // Convert msb based on the palette + t = texelFetch(PaletteSampler, ivec2((depth >> 8) & 0xFF, 0), 0) * 255.0f; + +#elif PS_URBAN_CHAOS_HLE == 1 // Depth buffer is read as a RGB5A1 texture. The game try to extract the green channel. // So it will do a first channel trick to extract lsb, value is right-shifted. // Then a new channel trick to extract msb which will shifted to the left. diff --git a/plugins/GSdx/res/glsl_source.h b/plugins/GSdx/res/glsl_source.h index b2261f1ccb..7225be1046 100644 --- a/plugins/GSdx/res/glsl_source.h +++ b/plugins/GSdx/res/glsl_source.h @@ -1079,7 +1079,14 @@ static const char* const tfx_fs_all_glsl = " ivec2 uv = ivec2(uv_f);\n" "\n" " vec4 t;\n" - "#if PS_URBAN_CHAOS_HACK == 1\n" + "#if PS_TALES_OF_ABYSS_HLE == 1\n" + " // Warning: UV can't be used in channel effect\n" + " int depth = fetch_raw_depth();\n" + "\n" + " // Convert msb based on the palette\n" + " t = texelFetch(PaletteSampler, ivec2((depth >> 8) & 0xFF, 0), 0) * 255.0f;\n" + "\n" + "#elif PS_URBAN_CHAOS_HLE == 1\n" " // Depth buffer is read as a RGB5A1 texture. The game try to extract the green channel.\n" " // So it will do a first channel trick to extract lsb, value is right-shifted.\n" " // Then a new channel trick to extract msb which will shifted to the left.\n"