d3d: Add basic stencil mask handling.

Mostly so we have it in dxstate, will probably reorganize stuff later.
Merge pull request #6811 from unknownbrackets/d3d9

d3d: Add basic stencil mask handling