I am trying to figure out how to implement batching in my OpenGL/DirectX based applications. I know that when depth test / depth write is enabled, I can put a bunch of objects that render with a common material in the same coordinate space and draw using a single draw call. But in my particular application, I have several objects that test against the depth buffer, but do not write to the depth buffer, and rely on draw order get the correct appearance. These are typically 2D geometry (e.g. a panel with dynamic information) in a 3D world.

Is there a general solution I can use to be able to batch items that normally need a specific draw order? Or do I need to tweak my scene and enable depth writing on everything to take advantage of batching?