D3D11 Clear Does Not Clip to Viewport

Reporter: RobertBColton  |  Status: open  |  Last Modified: April 25, 2019, 03:35:21 AM
I finally figured this out while working on #1636 and it's not a regression, it occurs on master too. The Microsoft Documentation is actually very clear (pun intended) about this.
https://docs.microsoft.com/en-us/windows/desktop/api/d3d11/nf-d3d11-id3d11devicecontext-clearrendertargetview

Unlike Direct3D 9, the full extent of the resource view is always cleared. Viewport and scissor settings are not applied.

The solution Microsoft proposes is actually that used by the Chromium/ANGLE projects at Google.
https://chromium.googlesource.com/angle/angle/+/chromium/2065/src/libGLESv2/renderer/d3d11/Clear11.cpp#82

However, I actually think the way GMS gets around this problem may be the fact that each view might have its own render target. This means the render target of each view is already the size of the view, hence no additional clipping during clear is necessary. The documentation isn't clear (pun again) whether they create you a surface for each view if you don't assign one (it sounds like they don't since that would be expensive).
https://docs.yoyogames.com/source/dadiospice/002_reference/windows%20and%20views/views/view_surface_id.html

it will return -1 if no surface has been assigned

Key to Success Title Screen Direct3D11

Key to Success Title D3D11

Key to Success Title Screen Direct3D9

Key to Success Title D3D11

Please sign in to post comments, or you can view this issue on GitHub.