Cannot get rid of z-fighting (severity varies between: no errors at all - ~40% fail).
* up-to-date validation layer has nothing to say.
* pipelines are nearly identical (differences: color attachments, descriptor sets for textures, depth write, depth compare op - LESS for prepass and EQUAL later).
* did not notice anything funny when comparing the draw commands via NSight either - except, see end of this post.
* "invariant gl_Position" for all participating vertex shaders makes no difference ('invariant' does not show up in decompile, but is present in SPIR-V).
* gl_Position calculations are identical for all (also using identical source data: push constants + vertex attribs)
However, when decompiling SPIR-V back to GLSL via NSight i noticed something rather strange:
Depth prepass has "gl_Position.z = 2.0 * gl_Position.z - gl_Position.w;" added to it. What is this!? "gl_Position.y = -gl_Position.y;", which is always added to everything, i can understand - vulcans NDC is vertically flipped by default in comparison to OpenGL. That is fine. What is the muckery with z there for? And why is it only selectively added?
Looking at my perspective projection code (the usual matrix multiplication, just simplified):
vec4 projection(vec3 v) { return vec4(v.xy * par.proj.xy, v.z * par.proj.z + par.proj.w, -v.z); }
All it ends up doing is doubling w-part of 'proj' in z (proj = vec4(1.0, 1.33.., -1.0, 0.2)). How does anything show at all given that i draw with compare op EQUAL. Decompile bug?
I am out of ideas.