Summary
OpenGL's polygon offset is used to avoid z-fighting when drawing primitives in line and points mode. Using the polygon offset feature results in an implementation defined depth offset, writing this offset depth to the framebuffer depth attachment makes performing a manual depth test hard. So only write depth when we are not using polygon offset and only use polygon offset once depth has been written.