mirror of https://github.com/PCSX2/pcsx2.git
glsl: add an HLE shader for Urban Chaos
Pro: * Replace 140 draw calls into a single one * No complex texture conversion/lookup * smaller solution than a generic solution
This commit is contained in:
parent
7d191ebf8e
commit
14e1ed06df
|
@ -779,6 +779,7 @@ 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_AEM %d\n", sel.aem)
|
||||
+ format("#define PS_TFX %d\n", sel.tfx)
|
||||
+ format("#define PS_TCC %d\n", sel.tcc)
|
||||
|
|
|
@ -289,8 +289,9 @@ class GSDeviceOGL final : public GSDevice
|
|||
|
||||
// Hack
|
||||
uint32 tcoffsethack:1;
|
||||
uint32 urban_chaos_hack:1;
|
||||
|
||||
uint32 _free2:16;
|
||||
uint32 _free2:15;
|
||||
};
|
||||
|
||||
uint64 key;
|
||||
|
|
|
@ -773,6 +773,10 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
|
|||
// Pop
|
||||
GL_INS("Red channel");
|
||||
ps_sel.channel = 1;
|
||||
} else if (0 && (tex->m_texture->GetType() == GSTexture::DepthStencil) /*&& !(rt->m_32_bits_fmt)*/) {
|
||||
// FIXME add a 16 bit check
|
||||
GL_INS("Urban Chaos Crazyness");
|
||||
ps_sel.urban_chaos_hack = 1;
|
||||
} else {
|
||||
GL_INS("channel not supported");
|
||||
m_channel_shuffle = false;
|
||||
|
|
|
@ -225,7 +225,21 @@ vec4 sample_depth(vec2 st)
|
|||
ivec2 uv = ivec2(uv_f);
|
||||
|
||||
vec4 t;
|
||||
#if PS_DEPTH_FMT == 1
|
||||
#if PS_URBAN_CHAOS_HACK == 1
|
||||
// Convert a GL_FLOAT32 to a special color format expected by the game
|
||||
int depth = int(fetch_c(uv).r * exp2(32.0f));
|
||||
|
||||
// Convert lsb based on the palette
|
||||
t = texelFetch(PaletteSampler, ivec2((depth & 0xFF), 0), 0);
|
||||
|
||||
// Msb is easier
|
||||
float green = float((depth >> 8) & 0xFF) * 36.0f;
|
||||
green = min(green, 255.0f);
|
||||
|
||||
t.g += green;
|
||||
|
||||
|
||||
#elif PS_DEPTH_FMT == 1
|
||||
// Based on ps_main11 of convert
|
||||
|
||||
// Convert a GL_FLOAT32 depth texture into a RGBA color texture
|
||||
|
@ -252,6 +266,7 @@ vec4 sample_depth(vec2 st)
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
// warning t ranges from 0 to 255
|
||||
#if (PS_AEM_FMT == FMT_24)
|
||||
t.a = ( (PS_AEM == 0) || any(bvec3(t.rgb)) ) ? 255.0f * TA.x : 0.0f;
|
||||
|
|
|
@ -1069,7 +1069,21 @@ static const char* const tfx_fs_all_glsl =
|
|||
" ivec2 uv = ivec2(uv_f);\n"
|
||||
"\n"
|
||||
" vec4 t;\n"
|
||||
"#if PS_DEPTH_FMT == 1\n"
|
||||
"#if PS_URBAN_CHAOS_HACK == 1\n"
|
||||
" // Convert a GL_FLOAT32 to a special color format expected by the game\n"
|
||||
" int depth = int(fetch_c(uv).r * exp2(32.0f));\n"
|
||||
"\n"
|
||||
" // Convert lsb based on the palette\n"
|
||||
" t = texelFetch(PaletteSampler, ivec2((depth & 0xFF), 0), 0);\n"
|
||||
"\n"
|
||||
" // Msb is easier\n"
|
||||
" float green = float((depth >> 8) & 0xFF) * 36.0f;\n"
|
||||
" green = min(green, 255.0f);\n"
|
||||
"\n"
|
||||
" t.g += green;\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"#elif PS_DEPTH_FMT == 1\n"
|
||||
" // Based on ps_main11 of convert\n"
|
||||
"\n"
|
||||
" // Convert a GL_FLOAT32 depth texture into a RGBA color texture\n"
|
||||
|
@ -1096,6 +1110,7 @@ static const char* const tfx_fs_all_glsl =
|
|||
"\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"\n"
|
||||
" // warning t ranges from 0 to 255\n"
|
||||
"#if (PS_AEM_FMT == FMT_24)\n"
|
||||
" t.a = ( (PS_AEM == 0) || any(bvec3(t.rgb)) ) ? 255.0f * TA.x : 0.0f;\n"
|
||||
|
|
Loading…
Reference in New Issue