godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.64k stars 21.11k forks source link

Vulkan: Sampling Depth Texture on Forward Mobile with MSAA is corrupted #80991

Open SeanH-CB opened 1 year ago

SeanH-CB commented 1 year ago

Godot version

4.1.1.stable

System information

Windows 10, Vulkan, NVidia GTX 1060 Driver Version 536.23

Issue description

On Forward Mobile having a Shader Material which samples the Depth Texture and having MSAA X2, X4, X8 enabled, causes the Depth Textures sampled data to be corrupted. Most likely its missing an MSAA Resolve before being bound.

Mobile: Depth Readback Mobile

Forward+ Depth Readback Forward+

Steps to reproduce

Minimal reproduction project

Depth Readback Repo.zip

SeanH-CB commented 1 year ago

60255

Seems like its a similar issue which was closed off as not reproducible

Calinou commented 1 year ago

cc @BastiaanOlij

BastiaanOlij commented 1 year ago

This is because the subpass system only has resolve for color buffers implemented. So the depth buffer isn't resolved and thus the buffer you're reading from is never properly populated.

I have a fix for this: https://github.com/godotengine/godot/pull/78598

But it relies on an extension that hasn't got enough coverage. I'm still looking into a fallback approach that works