Skip to main content

Module render_target

Module render_target 

Source
Expand description

Off-screen render targets for cached widget subtrees and compositing.

RenderTarget owns an offscreen Rgba8Unorm texture that can be used as a RENDER_ATTACHMENT, and whose contents can be read back to CPU memory or sampled as a texture in subsequent render passes.

§Usage

  1. Create a RenderTarget with RenderTarget::new.
  2. Render into it by using RenderTarget::color_view as the colour attachment in a render pass.
  3. Optionally call RenderTarget::readback_rgba for CPU pixel access.
  4. Use RenderTarget::texture_view + a sampler to composite the target into a parent pass (e.g. via the textured pipeline).

Render targets support optional MSAA: pass sample_count > 1 to obtain a multisample render texture that resolves into the single-sample backing texture on each render pass. The backing texture (color_texture) is always sample_count=1 and COPY_SRC, making readback straightforward.

Structs§

RenderTarget
An off-screen GPU render target.