Adjustment for the depth range difference between opengl and vulkan rendering

I am porting an opengl based 3d rendering engine to vulkan. While porting, I see that there is issue due to depth precision which boils down to the difference in depth ranges used by opengl (-1 to 1) and vulkan (0 to 1). I am using glm::perspectiveRH_ZO for perspective calculation but still the depth near the near plane are coming almost same that the depth test is failing, and I can see the geometries flickering between different depths.

I want to how Godot handles this difference in its engine to display same project with opengl and vulkan both exactly in the same way w.r.t. depth test.

I don’t think Godot automatically handles the conversion, there is a short note about it in the shading section on depth textures

This tutorial assumes the use of the Forward+ or Mobile renderers, which both use Vulkan NDCs with a Z-range of [0.0, 1.0]. In contrast, the Compatibility renderer uses OpenGL NDCs with a Z-range of [-1.0, 1.0]. For the Compatibility renderer, replace the NDC calculation with this instead:

Yes, I came across this eariler (sorry to not have mentioned) but I was hoping for any other solution without impacting shader.

Just to give you an idea what all I have tried:

  1. using depth precision of 32 but instead of 16 bit solves the issue
  2. shifting near plane value from 1 to 1000 solves the issue
    the above two solution impacts the depth values directly in different ways though.
  3. using GLM_FORECE_DEPTH_ZERO_TO_ONE (a well known solution for this) does NOT solve my issue.
  4. I referred this article as well: Vulkan’s coordinate system – AnKi 3D Engine Dev Blog
    this mentions 2 solutions, the first one I have already tried and did NOT work but the 2nd solution which it mentions about refactoring the code, is little unclear to me. Basically, he follows below 3 steps:

    what does he exactly mean by the first and the last point? What needs to be changed?

Is there any other solution without overloading the shader?

I cannot use 32 bit precision as it has to be compatible with opengl version which is working fine with 16 bit. Same for near plane.

I checked on godot, and it seems that, for some setting of near/far plane for a scene/project, the godot also shows z fightig in forward+ and not in compatibility mode. Am I right in this observation or am I missing some setting in godot which can be useful in making same project work exactly same in both modes even if the depth settings are prone to z fighting for forward+/vukan?