I would like to render two meshes, the first one writing into the stencil buffer and the second one testing against it. I want to do that on a per fragment level though (the fragment shader of the first object should define which value to write into the stencil buffer and the fragment shader of the second object should define whether and against which stencil value the fragments of the second object should be clipped).
My Target Platform is the Oculus Quest 2, which has a Qualcomm Snapdragon XR.
If the platform would support GL_ARM_shader_framebuffer_fetch_depth_stencil, I could use that, but that's only supported on some Mali GPUs.
The reason I want to use stencils is that I want to render everything in a single forward rendering pass for performance reasons and since I'm already forced to use fragment discard in my shaders, early z-rejection is off the table anyway so that's not a concern.
How can I achieve per fragment stencil writing/testing on Qualcomm Snapdragon XR2 in either OpenGL ES 3.0 or Vulkan?
any pointers are appreciated.