EVALUATION
We have to clip incoming coordinates because otherwise SetScissorRect fails
with the debug d3d runtime. Unfortunately the clipping code doesn't do it
correctly in some cases.
The clipping code looks like this:
if (x1 < 0) x1 = 0;
if (y1 < 0) y1 = 0;
if ((UINT)x2 > desc.Width) x2 = desc.Width;
if ((UINT)y2 > desc.Height) y2 = desc.Height;
if (x1 > x2) x2 = x1;
if (y1 > y2) y2 = y1;
RECT newRect = { x1, y1, x2, y2 };
It is not correct for cases when say, both x1 and x2 are greater than
render target's width. In this case we'll end up with
x1 == x2 > desc.Width. Same with y1/2 and Height.
The fix is to set both x1,x2 or y1,y2 to 0 if the clip rect is empty
so that scissor rect is empty.
|