It was probably related to some interaction [driver bug ?] of different sizes of original (640x480) DepthBuffer and your new (512x512) renderTarget.
You can try to create and set new DepthBuffer with 512x512 size and assign at the same time with new renderTarget.

PS. Creating / destroying VertexBuffer each frame is REALLY BAD!