Hi there, there is a very problematic bug in Dolphin that is currently impacting both Pi4 and Pi5 users where a significant number of games are currently unplayable due to the Pi not supporting Dual Source Blending or GL_EXT_shader_framebuffer_fetch :
https://bugs.dolphin-emu.org/issues/13556
This bug is rendering a substantial set of games on both Pi's unplayable. this includes: Metroid Prime, Mario Kart Double Dash, Resident Evil 4 and Mario Golf Toadstool Tour (as well as probably loads of others). In the case of Mario Golf and Metroid, characters/maps are completely invisible while in Mario Kart and Resident Evil I understand that the screen colour is massively impacted.
This problem first surfaced in dolphin-5.0-1653 after the alpha pass functionality was removed from dolphin. Unfortunately, compiling older version of dolphin on the latest Pi OS (Bookworm) is difficult and I have not been able to achieve decent performance. Sadly, falling back to the 5 year old 32-bit Buster OS actually allows for better dolphin performance on the Pi4 right now as dolphin 4.0 can be easily built and plays these games much better than current builds can (that said, this wouldn't even be an option for Pi5 users).
I am trying to resolve this bug myself as I want to be able to play these games on the latest Pi OS. I really don't know what I am doing in terms of shader development but I have been researching other emulators and I came across a potential solution that I would like to get your thoughts on. In PPSPP, in the below FragmentShaderGenerator.cpp module, there appears to be a work around for when framebuffer_fetch is not available using texelfetch:
https://github.com/hrydgard/ppsspp/blob/...erator.cpp
In this implementation, it appears that texelFetch is serving in place of framebuffer_fetch when it is not available.
Do you think that this could be a potential solution for dolphin? Any thoughts or ideas that you might have would be very much appreciated. I have already tired implementating the solution as best as i could in the dolphin source code but, as I have said, I really don't know what i am doing and so I am not sure if what I am doing even has the potential to work. I have tried making the changes in both ../Source/Core/VideoCommon/PixelShaderGen.cpp and ../Source/Core/VideoCommon/UberShaderPixel.cpp using a current dolphin build but the problem is not going away. I would just really appreciate any help that you could give me here.
Thank you.
https://bugs.dolphin-emu.org/issues/13556
This bug is rendering a substantial set of games on both Pi's unplayable. this includes: Metroid Prime, Mario Kart Double Dash, Resident Evil 4 and Mario Golf Toadstool Tour (as well as probably loads of others). In the case of Mario Golf and Metroid, characters/maps are completely invisible while in Mario Kart and Resident Evil I understand that the screen colour is massively impacted.
This problem first surfaced in dolphin-5.0-1653 after the alpha pass functionality was removed from dolphin. Unfortunately, compiling older version of dolphin on the latest Pi OS (Bookworm) is difficult and I have not been able to achieve decent performance. Sadly, falling back to the 5 year old 32-bit Buster OS actually allows for better dolphin performance on the Pi4 right now as dolphin 4.0 can be easily built and plays these games much better than current builds can (that said, this wouldn't even be an option for Pi5 users).
I am trying to resolve this bug myself as I want to be able to play these games on the latest Pi OS. I really don't know what I am doing in terms of shader development but I have been researching other emulators and I came across a potential solution that I would like to get your thoughts on. In PPSPP, in the below FragmentShaderGenerator.cpp module, there appears to be a work around for when framebuffer_fetch is not available using texelfetch:
https://github.com/hrydgard/ppsspp/blob/...erator.cpp
Code:
bool fetchFramebuffer = needFramebufferRead && id.Bit(FS_BIT_USE_FRAMEBUFFER_FETCH);
bool readFramebufferTex = needFramebufferRead && !id.Bit(FS_BIT_USE_FRAMEBUFFER_FETCH);
Code:
// Two things read from the old framebuffer - shader replacement blending and bit-level masking.
if (readFramebufferTex) {
if (compat.shaderLanguage == HLSL_D3D11) {
WRITE(p, " vec4 destColor = fbotex.Load(int3((int)gl_FragCoord.x, (int)gl_FragCoord.y, 0));\n");
} else if (compat.shaderLanguage == HLSL_D3D9) {
WRITE(p, " vec4 destColor = tex2D(fbotex, gl_FragCoord.xy * u_fbotexSize.xy);\n", compat.texture);
} else if (compat.shaderLanguage == GLSL_VULKAN) {
WRITE(p, " lowp vec4 destColor = %s(fbotex, ivec3(gl_FragCoord.x, gl_FragCoord.y, %s), 0);\n", compat.texelFetch, useStereo ? "float(gl_ViewIndex)" : "0");
} else if (!compat.texelFetch) {
WRITE(p, " lowp vec4 destColor = %s(fbotex, gl_FragCoord.xy * u_fbotexSize.xy);\n", compat.texture);
} else {
WRITE(p, " lowp vec4 destColor = %s(fbotex, ivec2(gl_FragCoord.x, gl_FragCoord.y), 0);\n", compat.texelFetch);
}
} else if (fetchFramebuffer) {
// If we have EXT_shader_framebuffer_fetch / ARM_shader_framebuffer_fetch, we skip the blit.
// We can just read the prev value more directly.
if (compat.shaderLanguage == GLSL_3xx) {
WRITE(p, " lowp vec4 destColor = %s;\n", compat.lastFragData);
} else if (compat.shaderLanguage == GLSL_VULKAN) {
WRITE(p, " lowp vec4 destColor = subpassLoad(inputColor);\n");
} else {
_assert_msg_(false, "Need fetch destColor, but not a compatible language");
}
}
In this implementation, it appears that texelFetch is serving in place of framebuffer_fetch when it is not available.
Do you think that this could be a potential solution for dolphin? Any thoughts or ideas that you might have would be very much appreciated. I have already tired implementating the solution as best as i could in the dolphin source code but, as I have said, I really don't know what i am doing and so I am not sure if what I am doing even has the potential to work. I have tried making the changes in both ../Source/Core/VideoCommon/PixelShaderGen.cpp and ../Source/Core/VideoCommon/UberShaderPixel.cpp using a current dolphin build but the problem is not going away. I would just really appreciate any help that you could give me here.
Thank you.