Resolve depth buffer in mobile renderer when required#78598
Resolve depth buffer in mobile renderer when required#78598Repiteo merged 1 commit intogodotengine:masterfrom
Conversation
d4b4f44 to
db2e8d9
Compare
|
I need to do some more testing but I think this also solves #78544 |
|
I think there should be 100% a fallback as the mobile renderer works better on older pc and it also has to support mobile, which nowadays it vulkan support is not the best. |
|
@Saul2022 agreed though I'd like to mark all the "todos" for future PRs. This is an important fix I'd like to get into 4.1 and the fix window closes Monday. As currently resolving doesn't work plus we have a number of validation errors that are solved by this, this is a step forward and shouldn't break anything that isn't already broken. @clayjohn @akien-mga I'm marking this for review due to the above reason if you guys are ok with that. |
|
As discussed on chat, let's not rush it now, but this is a good candidate for 4.1.1 once finalized and merged for 4.2. |
|
Does this resolve #78785? |
|
@Calinou I don't think so, but that is one I need to find time for |
db2e8d9 to
b3c9081
Compare
b3c9081 to
f12e564
Compare
|
Is this still getting merged? I also got the same issue on my XR project so I wonder if there are any workarounds too. |
|
@BastiaanOlij Do you plan to update this one now that the subpasses merge PR got upstreamed? |
|
@Stratapeum this got stuck because we have no fallback if the extension is not supported. I'm not sure if @DarioSamo is looking into this as resolving depth buffer has become important for other purposes. |
|
cc @clayjohn is it worth reviving this as is or do you guys have other plans around the work that has recently been done? |
I don't have any plans for working on this myself if that is what you are asking. |
f12e564 to
e46f61b
Compare
|
|
||
| if (use_msaa && has_depth_texture_override && !supports_depth_resolve) { | ||
| // We don't have a fallback for this, See PR #111322 | ||
| WARN_PRINT_ONCE("MSAA Depth buffer resolve is not supported on this platform."); |
There was a problem hiding this comment.
I just added this warning in JIC, this would require completion of #111322 however see notes on that PR for the issues we're running into.
That said, on the devices where this is important, it seems that our Vulkan Extension is available so I feel this should not hold up merging.
| SUPPORTS_BUFFER_DEVICE_ADDRESS, | ||
| SUPPORTS_IMAGE_ATOMIC_32_BIT, | ||
| SUPPORTS_VULKAN_MEMORY_MODEL, | ||
| SUPPORTS_FRAMEBUFFER_DEPTH_RESOLVE, |
There was a problem hiding this comment.
I am not sold on this name...
e46f61b to
9e5fad8
Compare
|
I'm out of the loop for a while so tested for both 4.6-dev1 and this PR artifacts, using the Windows editor with the Android template. For the both versions, the old Samsung Galaxy s10 (2019) and the Samsung Galaxy s25 seems to work with and without MSAA 4x. for 4.5-stable the depth buffer doens't work with MSAA 4x as expected. Not sure why it works on 4.6-dev1 (Edit: just found #108636, that's awesome), but everything seems to run ok. Also tested my personal project, and shaders that depends on the depth buffer seems to work without issues. Excellent job! |
|
Bump for progress. This is required before we can enable MSAA on visionOS immersive rendering. |
Are you sure? This is an optimization for certain GPUs, but doesn't change functionality |
The only thing I need is a correctly resolved depth buffer. VisionOS needs depth output to display correctly. Here is an example showing what will happen if depth is not correctly configured. Depth buffer is not correctly resolved in current implementation. I tried other workarounds, including force So yes, there can be two way to fix this. One is fixing manual depth resolve on metal (for layered depth texture), the other one is implement hardware depth resolve for metal after this PR get merged. It is very easy to implement depth resolve on metal, and I have a working implementation. Hardware depth resolve should be supported on all apple platforms current godot targets. Its support starts from A9 chip, used ten years ago in iPhone 6s. iPhones older than that does not support iOS 14, the min target iOS version of godot. So implement hardware depth resolve is my goto solution. It is faster, more general, does not introduce platform specific code in forward mobile renderer. I don't see the value to fix manual depth resolve on metal. I don't know why this PR is stalled from merging if this is merely an optimization. If you worry about extension coverage, this extension have more than 70% coverage on android, 100% coverage on iOS (moltenVK) if you check vulkan database. |
|
@huisedenanhai indeed very important for VisionPro however the solution there is found inside the metal driver, not related to Vulkan. |
It is not related to vulkan. But the fix in metal driver needs new RenderingDevice depth attachment resolve APIs, which is introduced in this pr. |
Ah, gotcha! I got a few small changes left to do but we should be able to move on it quickly. |
9e5fad8 to
21ffbec
Compare
|
@clayjohn I've added in the There are a few XR use cases waiting on this so it would be good if you could have a peek at it :) |
|
Thanks! |
|
With this PR, I got a lots of error in console output (Windows 11) : Godot Engine v4.6.dev.custom_build.2edc43df8 (2025-11-20 17:10:48 UTC) - https://godotengine.org ERROR: Format 'D24_Unorm_S8_Uint' does not support usage as storage image. To reproduce:
|

This PR fixes a long standing issue with the mobile renderer when using MSAA. The subpass logic never had an option for resolving the MSAA depth buffer to a normal depth buffer.
This meant that:
This PR does rely on the VK_KHR_depth_stencil_resolve extension. This has been core since Vulkan 1.2 and was a KHR extension in Vulkan 1.0/1.1 and may not be supported on all GPUs.
Todos: