ShaderX6: Stable Rendering of Cascaded Shadow Maps (Michal Valient) has a good description.
Basically, pick a world-space point as your “quantization origin”, project it to shadow space, and then subtract from it that shadow space position rounded to the nearest texel. This “correction” offset can be appended to the shadow matrix (used for shadow projection). Essentially this keeps the quantization origin on the corner of a shadow texel, effectively making your shadow map march along in one shadow texel increments.
Beware getting your quantization origin too far from your shadow map though (floating point precision issue).
Haven’t read his presentation, but looks like there’s a mode where shadow texel sizes can be multiples of the base shadow map resolution.
where should I apply this fix (I guess it must be fragment shader) ?
No, you can just quantize your light-space frustum (built on the CPU) using this offset, with your shader remaining oblivious. Basically, just use the offset to scoot your light-space frustum over a tiny bit in XY in light space.