flyinghead / flycast

Flycast is a multiplatform Sega Dreamcast, Naomi, Naomi 2 and Atomiswave emulator
GNU General Public License v2.0
1.37k stars 167 forks source link

Shaders causing graphical issues with D3D11 renderer #1612

Open bslenul opened 3 weeks ago

bslenul commented 3 weeks ago

Platform / OS / Hardware: PC / Windows 10 / i5-12400F / RTX 3060 Ti

Github hash: 349083030d85d9e7ae44bddf05090952c6e2bfbc

Description of the Issue

When enabling shaders while using the D3D11 video driver, it creates graphical issues, see the screenshots below.

Just noticed it while trying to reproduce this issue (I usually use Vulkan and no shaders with Flycast so I never noticed it before): https://www.reddit.com/r/RetroArch/comments/1f01yq8/flycast_core_in_retroarche_will_not_display_game/

Note that once the graphics are "corrupted", disabling shaders doesn't fix it.

Debugging Steps Tested

Haven't tried much so far besides resetting core options to default and testing an older random commit from early 2022 (830ffd0) which already exhibits the issue.

I also tried other Libretro cores to make sure it was not a RetroArch issue, but shaders look fine in Dolphin, LRPS2 and SwanStation cores when using their D3D11 renderer.

Screenshots

Screenshots took while using the "crt-geom" CRT preset.

flyinghead commented 3 weeks ago

I believe this has been reported before but I have no idea what could cause this.

bslenul commented 3 weeks ago

Ah my bad, I searched for "D3D11" and "shader" but couldn't find any issue about this 🤔

Also, I have no idea if this is relevant or not but I tried ReShade instead of the internal RetroArch shaders and no issue at all with the few shaders I tested.

mfigueirido commented 3 weeks ago

I always play on Vulkan and shaders work fine. Made a test with D3D11 and got this:

No shaders: noshader

With shaders: shader

If I have to bet on what is happening is that the DirectX shader passes are somehow clashing with Flycast's internal render targets. RetroArch is creating its render targets on top of Flycast's render targets and clearing them, that's why some geometry is missing. Maybe those render targets are released but Flycast keeps using them?