If we let quads be special and draw them as though they are opaque within a layer and let them write to the depth buffer we can draw them in reverse order as the first step before batching other primitives and let them overwrite rather than blend with previous quads.
To do this we will have to include the layer index in the primitives we upload to the gpu as the z component of the position.