Depth only rendering on mobile devices

Hi,

“Depth only” rendering does not work correctly on mobile devices. I have created a blank game and placed some cubes in it, as seen below.

The nearest cube is black as I set its “Render in Main Pass” to false, and left the “Render in Depth Pass” as true. So it is invisible, but occludes objects behind it. This is what I want.

Screenshot 2023-07-26 at 14.15.51

When I play the game in the viewport, it renders correctly:

But when I launch the game on a mobile device, depth test does not work, the nearest cube is invisible, but does not occlude the two others behind it:

It is the same on ios and android as well. I have tried forward and deferred shading as well, neither worked. Note that launching the game on a mac the result is correct. But on mobile devices it is not. I have tested with engine version 5.2.1.

Is there any solution to make it correctly work on mobile devices as well?