Description
Right now, we don't write to a depth or stencil buffer for draw calls that render solid strokes/fills, and overlapping triangles in the same draw call just draw on top of each other.
Here's the equivalent Skia Fiddle for reference:
https://fiddle.skia.org/c/027392122bec8ac2b5d5de00a4b9bbe2
Since we're already using the stencil check for the clip stack, one solution would be to use shallow depth attachments per render target, increment the geometry depth slightly with each draw call, draw with MTLCompareFunction.greater
, and clear the depth buffer whenever we have enough solid strokes/fills drawn to the target such that we need to loop around.
@chinmaygarde Does the above seem like a reasonable approach to you? We could also trade the increased device memory for solutions with more draw calls (like increment the stencil buffer and discard fragments that don't match the current stencil height, then draw a clip restore at the previous max height), but I suspect we're doing pretty good in the device memory department right now.