Download

Slate stencil and offscreen rendering

Hello,

I’ve got a custom Slate widget that requires doing some rendering to an offscreen render target, that is then used in the final pass which requires a stencil buffer. Everything is working at the moment, but my main concern is trying to avoid costly buffer copies in tiled GPUs. What I’m doing at the moment is that the widget creates two ICustomSlateElement, one for the offscreen pass that I assign to layer 0, and the final pass that goes into whichever layer is passed in OnPaint. In both elements I first set the render target buffers (both color and depth/stencil, but in the main pass the color buffer is the one already set), and then restore them. I have several questions:

  • Does changing the depth/stencil buffer while leaving the color buffer the same break up tiling and force moving the color buffer contents off chip? (Haven’t tried myself)
  • I see there’s some support for stencil buffer in Slate (FSlateRHIRenderer:: DrawWindows_Private), but it’s a bit broken. Would you take a pull request if I refreshed that adding support for elements to express their need of a stencil buffer (like now viewports can require vsync)?
  • Is there a way for slate to create and set the buffers for the offscreen pass so I don’t have to call SetRenderTarget myself? Is a viewport the way to achieve this?

Thank you!