Wireframe not visible when drawn after solid pipeline with same shader output

I use two graphics pipelines:

  • solid (VK_POLYGON_MODE_FILL)
  • wireframe (VK_POLYGON_MODE_LINE)

Both pipelines work correctly when rendered individually.

However, when drawing them together (solid first, then wireframe), the wireframe is not visible because both pipelines use the same fragment shader and output the same color, so the wireframe pass overwrites identical pixels.


Question

What is the common practice for drawing wireframe over solid geometry?

Does your depth testing mode allow for fragments of equal depth to be overwritten (i.e. VK_COMPARE_OP_LESS_OR_EQUAL or similar)?
Otherwise/additionally you can apply polygon offset (vkCmdSetDepthBias or corresponding members of VkPipelineRasterizationStateCreateInfo) to push the solids slightly away from (or pull the wireframe slightly closer to) the camera.

It was caused by the wireframe and normal outputs having the same color because I was using the same shader for both, which made the wireframe lines invisible. I fixed it by using a separate, dedicated shader for the wireframe, and it now works.