gsdx-ogl: fix 2 passes DATE with GL42 (override_GL_ARB_shader_image_load_store = 1)

It fixes shadows issue with Persona 3
This commit is contained in:
Gregory Hainaut 2015-05-02 16:56:18 +02:00
parent 14a1925de0
commit ae70344fbc
2 changed files with 12 additions and 20 deletions

View File

@ -423,14 +423,16 @@ void ps_main()
// Pixel with alpha equal to 1 will failed
float rt_a = texelFetch(RtSampler, ivec2(gl_FragCoord.xy), 0).a;
if ((127.5f / 255.0f) < rt_a) { // < 0x80 pass (== 0x80 should not pass)
discard;
imageStore(img_prim_min, ivec2(gl_FragCoord.xy), ivec4(-1));
return;
}
#elif (PS_DATE & 3) == 2 && !defined(DISABLE_GL42_image)
// DATM == 1
// Pixel with alpha equal to 0 will failed
float rt_a = texelFetch(RtSampler, ivec2(gl_FragCoord.xy), 0).a;
if(rt_a < (127.5f / 255.0f)) { // >= 0x80 pass
discard;
imageStore(img_prim_min, ivec2(gl_FragCoord.xy), ivec4(-1));
return;
}
#endif
@ -474,25 +476,19 @@ void ps_main()
// Pixel with alpha equal to 1 will failed (128-255)
if (c.a > 127.5f / 255.0f) {
imageAtomicMin(img_prim_min, ivec2(gl_FragCoord.xy), gl_PrimitiveID);
return;
}
#elif PS_DATE == 2 && !defined(DISABLE_GL42_image)
// DATM == 1
// Pixel with alpha equal to 0 will failed (0-127)
if (c.a < 127.5f / 255.0f) {
imageAtomicMin(img_prim_min, ivec2(gl_FragCoord.xy), gl_PrimitiveID);
return;
}
#endif
#if (PS_DATE == 2 || PS_DATE == 1) && !defined(DISABLE_GL42_image)
// Don't write anything on the framebuffer
// Note: you can't use discard because it will also drop
// image operation
#else
SV_Target0 = c;
SV_Target1 = vec4(alpha, alpha, alpha, alpha);
#endif
}
#endif

View File

@ -1164,14 +1164,16 @@ static const char* tfx_fs_all_glsl =
" // Pixel with alpha equal to 1 will failed\n"
" float rt_a = texelFetch(RtSampler, ivec2(gl_FragCoord.xy), 0).a;\n"
" if ((127.5f / 255.0f) < rt_a) { // < 0x80 pass (== 0x80 should not pass)\n"
" discard;\n"
" imageStore(img_prim_min, ivec2(gl_FragCoord.xy), ivec4(-1));\n"
" return;\n"
" }\n"
"#elif (PS_DATE & 3) == 2 && !defined(DISABLE_GL42_image)\n"
" // DATM == 1\n"
" // Pixel with alpha equal to 0 will failed\n"
" float rt_a = texelFetch(RtSampler, ivec2(gl_FragCoord.xy), 0).a;\n"
" if(rt_a < (127.5f / 255.0f)) { // >= 0x80 pass\n"
" discard;\n"
" imageStore(img_prim_min, ivec2(gl_FragCoord.xy), ivec4(-1));\n"
" return;\n"
" }\n"
"#endif\n"
"\n"
@ -1215,25 +1217,19 @@ static const char* tfx_fs_all_glsl =
" // Pixel with alpha equal to 1 will failed (128-255)\n"
" if (c.a > 127.5f / 255.0f) {\n"
" imageAtomicMin(img_prim_min, ivec2(gl_FragCoord.xy), gl_PrimitiveID);\n"
" return;\n"
" }\n"
"#elif PS_DATE == 2 && !defined(DISABLE_GL42_image)\n"
" // DATM == 1\n"
" // Pixel with alpha equal to 0 will failed (0-127)\n"
" if (c.a < 127.5f / 255.0f) {\n"
" imageAtomicMin(img_prim_min, ivec2(gl_FragCoord.xy), gl_PrimitiveID);\n"
" return;\n"
" }\n"
"#endif\n"
"\n"
"\n"
"#if (PS_DATE == 2 || PS_DATE == 1) && !defined(DISABLE_GL42_image)\n"
" // Don't write anything on the framebuffer\n"
" // Note: you can't use discard because it will also drop\n"
" // image operation\n"
"#else\n"
" SV_Target0 = c;\n"
" SV_Target1 = vec4(alpha, alpha, alpha, alpha);\n"
"#endif\n"
"\n"
"}\n"
"\n"
"#endif\n"