Its been a while, but the basic idea for a z-prepass is this:
You render your entire scene once, but only to the depth-buffer. What that means is, in DX10 upwards, you can bind a null-pixelshader. So you render each object with its normal vertex-shader, but without any pixel-shader. You bind the depth-buffer that you wan to fill, with the normal settings like if you would render your scene (write+read, fail-if-behind-or-equal). And then once your scene has been processed once, this is your z-prepass. Oh, you should optimally also try to cut everything else for that pass. If you can, you keep position in a separate vertex-buffer and only bind this for this pass (unless you do texture-based vertex displacement of course).
The next point - your normal pass. You use the same depth-buffer, and now you render everything as usual. With a small modification - you set the depth-state to “read only", and set it to fail-if-behind (basically only fragments at the same z should pass).
Unless I'm really mixin something up, thats it. I don't think this is something that can be done automatically, but it can give you a good gain if done correct, especially if you have complex fragment-shader and lots of overdraw. The z-prepass as previously descripted is really cheap - no fragments are emitted at all, and if you can bind only the position than the restrictions on bandwidth are also pretty minimal. Then during your regular pass, you have to execute way lass fragments than you would have to do - of course this does depend on your scene (and is also pretty useless for deferred rendering if I recall correctly since the fragment-shader for the scene-pass there is already pretty cheap).